For Loop Countdown in C

Level 267 keystrokes

Uses a for loop that counts i down from 5 to 1, printing each number, then prints "Go!": "5 4 3 2 1 Go!".

C code

// Counts down: i starts at 5, runs while i >= 1, and i-- lowers it by 1 each pass
1for (int i = 5; i >= 1; i--) {
// Prints 5, 4, 3, 2, 1, each followed by a space
2 printf("%d ", i);
3}
// Runs once after the loop ends and finishes the line with "Go!"
4printf("Go!\n");

Output

5 4 3 2 1 Go!
Practice typing this code

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.

  • ;× 4
  • "× 4
  • (× 3
  • )× 3
  • -× 2
  • =× 2
  • ,× 1
  • !× 1
  • {× 1
  • }× 1

More C examples at level 2

← C typing practice