If-Else Statement in C++

Level 284 keystrokes

Checks with if-else whether n (15) is greater than 10; since it is, the program prints Big.

C++ code

// Declares the int variable n and initializes it with 15
1int n = 15;
// Tests the condition n > 10; 15 > 10 is true
2if (n > 10) {
// Runs because the condition is true and prints Big
3 cout << "Big" << endl;
// The else branch runs only when the condition is false
4} else {
// Would print Small if n were 10 or less; skipped here
5 cout << "Small" << endl;
6}

Output

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

  • <× 8
  • "× 4
  • ;× 3
  • {× 2
  • }× 2
  • (× 1
  • )× 1
  • =× 1
  • >× 1

More C++ examples at level 2

← C++ typing practice