Number of sub-classes · C language-condition statements and C language statements
First of all, let's talk about the theoretical knowledge. There are three structures in programming: sequential structure, conditional structure, and cyclic structure. If they are expressed using flowcharts:
In C, how can we use these three structures flexibly? This requiresControl statement.
WhileCondition StatementIs one of the control statements.
Generally, there are three condition statements in C language:IfStatement,If ...... ElseStatement andSwitchStatement
Next we will introduce the three statements respectively.
I. if statement
(Use the if statement to implement a branch of the above condition structure)
II. if ...... Else statement
(If ...... The else statement implements the above conditional structure)
Iii. switch statements
(Now we use the switch statement to implement an input number and output its corresponding notes)
Conclusion: The if statement only determines if yes;
If ...... The else statement not only determines the yes condition, but also determines the no condition;
The switch statement determines a specific situation and its exceptions.
When compiling a C program, select the appropriate condition statement to achieve the designed effect.