--for statement: Specify the number of times --while statement: Condition specification (first judgment) --do ~ while statement: Condition specification (post-judgment)
int i;
for (i = 1;i <=Number of iterations;i++) {
Repeated sentence;
}
This can be used for all loop processing.
break;
--Judge the conditional expression before execution
while (Conditional expression) {
Repeated sentence;
}
If you want to use it like for, write as follows
Initialization;
while (Conditional expression) {
Repeated sentence;
update;
}
--Judge the condition after execution --Use this if you want to execute it once
――Effective when checking input. When you re-enter if you make a mistake
do {
Repeated sentence;
} while (Conditional expression);
Recommended Posts