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

for and while

What's the differences between for and while?

15th Feb 2017, 8:07 AM
Derry
3 Answers
+ 7
while (condition) { //codes index++; } for (initialization; condition; index++) { // codes }
15th Feb 2017, 12:04 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
initialisation; while(test_condition) { body; iteration; }
15th Feb 2017, 12:27 PM
Mr.Robot
Mr.Robot - avatar
+ 4
@Hatsy The index doesn't have to be increased by one.
15th Feb 2017, 8:14 PM
J.G.
J.G. - avatar