There are three loops in C: for, while, and do-while. What's the difference between them? Answer
A while loop will always evaluate the condition first.
while (condition) {
//gets executed after condition is checked
}
A do/while loop will always execute the code in the do{} block first and then evaluate the condition.
do {
//gets executed at least once
} while
A for loop allows you to initiate a counter variable, a check condition, and a way to increment your counter all in one line.
for (int x = 0; x < 100; x++) {
//executed until x >= 100
}
More details can be seen at the original answer, here I just cite some that are useful for myself.
支付宝
微信