How to use C language sentence and selection structure
This article mainly introduces the relevant knowledge of "how to use C language sentence and choice structure". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "how to use C language sentences and choice structure" can help you solve the problem.
Knowledge point 1-statement 1.1 statement 1. Expression statement
An expression statement is made up of an expression plus a semicolon, and its general form is as follows:
Expression.
Q1: what is an expression?
A1: an expression is a formula made up of operators and data in C language; the result of an expression operation is called the value of an expression, and here are some common expressions.
/ / expression
one
-5
4: 20
X = qflux +% 3
A * (b + cplink d) / 20
Q > 3
Kiko: so the expression statement is done by adding a semicolon after the above expressions.
/ / expression statement
1
-5
4: 20
X = qflux +% 3
A * (b + cplink d) / 20
Q > 3
two。 Control statement
As can be seen by the name, control statements are used to control the execution of the program, which is defined by specific statements. I personally divide the control statements in C language into the following three categories:
Select statement: if-else statement, switch-case statement.
Loop statement: while statement, do-while statement, break statement.
Jump statement: break statement, goto statement, continue statement.
In this issue, we will talk about the first of the three types of sentences, that is, select sentences!
3. Empty sentence
An empty statement is a statement with only one semicolon that does nothing in the program and may just play a placeholder role.
; / / empty statement
For (int item0; I