Array and Loop in C

Level 391 keystrokes

Declares an integer array and iterates through it using a for loop.

C code

// Five values; the size 5 is taken from the initializer list
1int nums[] = {10, 20, 30, 40, 50};
// Indexes run from 0 to 4, because C arrays start at index 0
2for (int i = 0; i < 5; i++) {
// Print the element at index i, one per line
3 printf("%d\n", nums[i]);
4}

Output

10
20
30
40
50
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.

  • ,× 5
  • ;× 4
  • "× 2
  • (× 2
  • )× 2
  • [× 2
  • ]× 2
  • {× 2
  • }× 2
  • +× 2

More C examples at level 3

← C typing practice