A while loop in One programming repeatedly executes a target statement as long as a given condition is true.
while (condition) {
// code block to be executed
}
int i = 0;
while (i < 5) {
cout << i << "\n";
i++;
}
☝️ | In the example above, the code in the loop will run, over and over again, as long as a variable (i) is less than 5. |
---|