For Loop in C

Level 364 keystrokes

Uses a for loop to print numbers from 1 to 5.

C code

// Start i at 1, loop while i <= 5, and add 1 after each pass
1for (int i = 1; i <= 5; i++) {
// Print i followed by a space, staying on the same line
2 printf("%d ", i);
3}
// End the line once after the loop: 1 2 3 4 5
4printf("\n");

Output

1 2 3 4 5
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 3

← C typing practice