Comparison Operator in C

Level 260 keystrokes

Compares x = 5 and y = 10 with <, == and >. Each comparison gives 1 if true and 0 if false, so it prints "1 0 0".

C code

// Declares the two values to compare: x = 5 and y = 10
1int x = 5, y = 10;
// A comparison yields the int 1 (true) or 0 (false): only x < y is true, so "1 0 0"
2printf("%d %d %d", x < y, x == y, x > y);

Output

1 0 0
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.

  • ,× 4
  • =× 4
  • %× 3
  • ;× 2
  • "× 2
  • (× 1
  • )× 1
  • <× 1
  • >× 1

More C examples at level 2

← C typing practice