Logical AND Operator in C

Level 259 keystrokes

Uses logical AND (&&) to check whether x (15) is between 10 and 20; both conditions are true, so it prints "In range".

C code

// The value to test is 15
1int x = 15;
// && is true only if both sides are true: 15 > 10 and 15 < 20 both hold
2if (x > 10 && x < 20) {
// Runs because x is inside the range and prints "In range"
3 printf("In range\n");
4}

Output

In range
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
  • &× 2
  • {× 1
  • }× 1
  • \× 1
  • <× 1
  • =× 1

More C examples at level 2

← C typing practice