Zero Padding in C

Level 121 keystrokes

Outputs an integer padded with leading zeros to 5 digits.

C code

// %05d pads the number with leading zeros to 5 characters
// Useful for formatting IDs, timestamps, or codes
1printf("%05d\n", 42);

Output

00042
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