What difference between while loop and for loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What difference between while loop and for loop?

10th Jul 2016, 2:45 PM
Vishal
Vishal - avatar
2 Answers
0
While is used when we dont know exactly how many number of times the loop should be executed. In most cases the user give the value of how many times the program should be executed. For is used when we exactly know how many number of times the loop should be executed. In most of the cases the programmer sets the value of number of times to be executed. Its that simple. GoodLuck. Rise & Shine.
11th Jul 2016, 7:30 PM
Rishan Mascarenhas
Rishan Mascarenhas - avatar
0
What if you embedded a for loop in a while loop but the while loop was infinitely false.
15th Jul 2016, 7:16 PM
Adam