While loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

While loops

can anybody please help me. i need help with while loops. thanks

6th Nov 2016, 9:40 AM
Osahon Emmanuel Jonathan-Odia
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 }
6th Nov 2016, 9:52 AM
Pierre Varlez
Pierre Varlez - avatar