+ 1

Can anyone explain loops to me please?

logic for loops

10th Oct 2016, 12:59 AM
Siddhanth
3 Answers
+ 1
A loop is a block of code that continues to run while a certain condition is true. while, do/while and for are all loops. e.g. int a = 1; while (a < 6) { cout << a; a++ //prints 12345 }
10th Oct 2016, 1:46 AM
Cohen Creber
Cohen Creber - avatar
0
Loop are flow control blocks... they control the "flow" of the program, allowing to repeat a number of times a block of code. Everything that is inside the loop block will execute (or no) as far as the conditions set on the loop allow it (the parameter evaluate to true in while and do-while loops and the third parameter on the for loop). Hope it helped.
10th Oct 2016, 1:46 AM
Nelson Urbina
Nelson Urbina - avatar
0
thanks
10th Oct 2016, 6:08 AM
Siddhanth