Do-While Loop in C
Level 381 keystrokes
Uses a do-while loop to print powers of 2 up to 8.
C code
// Start at 2^0 = 11int num = 1;// The body runs once before the condition is checked2do { // Print the current power of 23 printf("%d ", num); // Double it: 1 → 2 → 4 → 8 → 164 num *= 2;// When num becomes 16 the condition fails, so 16 is never printed5} while (num <= 8);// End the line: 1 2 4 86printf("\n");Output
1 2 4 8
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(× 3)× 3=× 3,× 1{× 1}× 1*× 1\× 1