Simple If Statement in C

Level 247 keystrokes

Checks with an if statement whether x (10) is greater than 5; the condition is true, so it prints "Greater".

C code

// x holds the value to test, 10
1int x = 10;
// The block runs only if the condition in parentheses is true; 10 > 5 is true
2if (x > 5) {
// Runs because the condition holds and prints "Greater"
3 printf("Greater\n");
4}

Output

Greater
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
  • "× 2
  • (× 2
  • )× 2
  • {× 1
  • }× 1
  • \× 1
  • =× 1
  • >× 1

More C examples at level 2

← C typing practice