Character ASCII Value in C

Level 252 keystrokes

Prints the same char variable twice: as a character with %c and as its ASCII code with %d, giving "Char: A, ASCII: 65".

C code

// A char is stored as a small integer: 'A' is stored as its code 65
1char c = 'A';
// %c shows the value as a character (A), %d as a number (65)
2printf("Char: %c, ASCII: %d\n", c, c);

Output

Char: A, ASCII: 65
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.

  • ,× 3
  • ;× 2
  • :× 2
  • '× 2
  • "× 2
  • %× 2
  • (× 1
  • )× 1
  • \× 1
  • =× 1

More C examples at level 2

← C typing practice