0
While loops
can anybody please help me. i need help with while loops. thanks
1 Answer
+ 1
When you do a while loop, you say that while the condition is respected, you do what is inside the block.
It's quite easy to make an infinite loop with a while, if you don't give a condition that can be false (for instance "while(1)"), in which case you can leave the loop using the "continue" keyword (maybe "break" in a few languages?)
While loops can be used the same way for loops work, for instance :
int i = 0;
while(i<10) {
//do stuff
i++;
}
is the same as
for(int i=0; i<10; i++) {
//do stuff
}