Width Specifier in C

Level 120 keystrokes

Outputs an integer right-aligned in a 5-character field.

C code

// %5d specifies a minimum field width of 5 characters
// The number is right-aligned, padded with spaces on the left
1printf("%5d\n", 42);

Output

   42
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.

  • "× 2
  • ,× 1
  • ;× 1
  • (× 1
  • )× 1
  • \× 1
  • %× 1

More C examples at level 1

← C typing practice