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 151int n = 15;// Tests the condition n > 10; 15 > 10 is true2if (n > 10) { // Runs because the condition is true and prints Big3 cout << "Big" << endl;// The else branch runs only when the condition is false4} else { // Would print Small if n were 10 or less; skipped here5 cout << "Small" << endl;6}Output
Big
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