Integer Array in C

Level 272 keystrokes

Declares an int array with the three elements 1, 2 and 3 and prints them by index as "1 2 3".

C code

// The size is left out, so the compiler counts the initializers: 3 elements
1int nums[] = {1, 2, 3};
// Indices start at 0, so nums[0] to nums[2] are the three elements: "1 2 3"
2printf("%d %d %d\n", nums[0], nums[1], nums[2]);

Output

1 2 3
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
  • ]× 4
  • %× 3
  • ;× 2
  • "× 2
  • (× 1
  • )× 1
  • {× 1
  • }× 1

More C examples at level 2

← C typing practice