Skip to content

Files

Latest commit

50c6995 · Aug 26, 2021

History

History
24 lines (18 loc) · 541 Bytes
·

while-loop.md

File metadata and controls

24 lines (18 loc) · 541 Bytes
·

While Loop

A while loop in One programming repeatedly executes a target statement as long as a given condition is true.

Syntax

while (condition) {
  // code block to be executed
}

Example

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.