0

What is a while loop?

The loop in a program.

10th May 2019, 10:58 PM
Shibu Christ
4 Réponses
+ 2
This video explains it well: https://youtu.be/7pAXm7WEA2I
11th May 2019, 12:48 AM
Big OC
Big OC - avatar
+ 8
The while loop is used to repeat a section of code an unknown number of times until a specific condition is met.
11th May 2019, 3:32 AM
Mr AJX 😎😈
Mr AJX 😎😈 - avatar
+ 3
While something is True, do something. So if you have a program that counts something, you can make it stop at a certian number, otherwise count forever .
10th May 2019, 11:08 PM
Ahri Fox
Ahri Fox - avatar
0
It basically says while a certain condition is met execute the given code For example if we have a variable declared as 5 and we write a while loop to increase the number and print it put: (not sure if this is a valid while loop it's just to illustrate the concept) int a = 5; while (a < 5) { a++; // increase a's value. cout << a << endl; // print a's value. } This code will print the following: 6 7 8 9 Hope this helps.
9th Jun 2019, 9:20 AM
Christiaan Strydom
Christiaan Strydom - avatar