Boolean type (BOOL): is a type of data that is not true or false.
Variables of type BOOL have only two values: YES (1) or NO (0).
In the C language, it is considered that a non 0 is true.
Relational operators
logical operators, with or not (&,|,!) Logic and: Simultaneous establishment of logic or: the same false is false logic is not: The result of the expression to reverse
Three structure of the program: sequential structure, branching structure, cyclic structure
If statement
Note: If a conditional expression cannot be added after a semicolon, the statement will be executed regardless of whether the conditional expression is valid
The second form of an if statement
if (conditional expression) {statement 1;} else {statement 2;}
Conditional operator
Three-mesh operator
Format: conditional expression. Expression 1: Expression 2//when the conditional expression is set up, the value of the condition 1 is executed, and the value of the execution condition 2 is given as follows:
max = (a>b)? A:B; Take the larger one in the variable A, B, and assign it to the variable max
Enum type enum
Switch statement
//
A multiple-spoke statement that determines which branch to execute by judging the value of an integer expression.
Switch often used with case
Switch syntax format
//
Switch (integer expression) {
Case value 1: statement 1;
break;//Case Value 2: statement 2;
Break
}
int A;
printf ("Enter number \ n");
scanf ("%d", &a);
Switch (a) {
Case 1:printf ("Spring \ n");
Case 2:printf ("Summer \ n");
Case 3:printf ("Fall \ n");
Case 4:printf ("Winter \ n");
default:printf ("input error, reenter \ n"); break;
Break is the end of the whole loop body, continue is the end of a single cycle