Variable Declaration in C

Level 262 keystrokes

Declares an int variable age (25) and a char variable grade ('A'), then prints both on one line as "25 A".

C code

// Declares an int variable age and stores the whole number 25 in it
1int age = 25;
// A char holds exactly one character, written in single quotes: here 'A'
2char grade = 'A';
// %d is replaced by age and %c by grade, so this prints "25 A" and a newline
3printf("%d %c\n", age, grade);

Output

25 A
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

More C examples at level 2

← C typing practice