Nested If in C++

Level 270 keystrokes

Uses an if inside another if to check that x (15) is greater than 10 and less than 20; both hold, so Between is printed.

C++ code

// Initializes x with 15
1int x = 15;
// Outer check: 15 > 10 is true, so the inner code runs
2if (x > 10) {
// Inner check, reached only if the outer one passed: 15 < 20 is true
3 if (x < 20) {
// Both conditions hold, so Between is printed
4 cout << "Between" << endl;
5 }
6}

Output

Between
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.

  • <× 5
  • ;× 2
  • "× 2
  • (× 2
  • )× 2
  • {× 2
  • }× 2
  • =× 1
  • >× 1

More C++ examples at level 2

← C++ typing practice