if
difference while
between
[ if
It is a judgment statement, while
a loop statement]
1. if
Judgment statement
if(判断条件) {
执行代码。。。
}
✍ If the condition is met, the code is executed; if not, the code cannot be executed.
2. while
Loop statement
while
The loop statement is divided into while
sum do-while
, the following is while
an example
while(循环条件) {
执行代码。。。
}
✍If the condition is met, execute the code; then judge whether the condition is met, if it is met, execute the code in a loop until the condition is not met, execute while
the code after the statement