In C++, the if function or keyword hasJudgment function, and judge this operationMust be based on the given conditions, and similarly, the program uses the if function in the same wayYou need to pass the judgment condition as a parameter, the ** statement describing the judgment condition is abbreviated asConditional statements。Just as there are matches or nots in real-life judgments, the same is true for if functions.
In the C language, the if function is special in that it must be combined with ** blocks to form a branching structure, and cannot be used like other ordinary functions. if function to open a branch of the program, which looks like this on **:
The program needs to be able to enter the branch of the program where if isIf and only if the condition determines that the result is true, i.e., the situation is compliant; When the condition judgment result is false, you cannot enter the if branch to execute **. If you need to handle the situation where the condition judgment result is false, you need to set the else branch with the else keyword, for example:
In C C++ programming, the if function can be used as an entry point for branching statements, as well as an exit out of a loop structure, such as:
For the above case, you need to make a reminder about the use of the if statementIf you don't use curly braces, the default scope of the if statement is from the parentheses to the first semicolonAs follows:
Although the syntax is supported, for beginners, I recommend putting curly braces on every if statement.
Just like controlling the jump out of a loop statement, C C++ programming often uses the if function judgment function to jump to the program to realize the jump execution between functions.