Do-While Loop in C++
Level 257 keystrokes
Uses a do-while loop, which runs its body before checking the condition, to print 1, 2 and 3.
C++ code
// Initializes the counter n with 11int n = 1;// do starts the body, which always runs at least once2do { // Prints the current value of n3 cout << n << endl; // Increases n by 1 for the next pass4 n++;// The condition is checked after the body; the loop ends when n becomes 45} while (n <= 3);Output
1 2 3
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 5;× 4+× 2=× 2(× 1)× 1{× 1}× 1