Ternary with Output in C++
Level 262 keystrokes
Puts a ternary expression directly inside cout to choose "Adult" or "Minor"; age is 20, so Adult is printed.
C++ code
// Initializes age with 201int age = 20;// The parentheses are needed because << binds tighter than ?:// 20 >= 18 is true, so the expression gives "Adult", which is printed2cout << (age >= 18 ? "Adult" : "Minor") << endl;Output
Adult
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;× 2=× 2:× 1?× 1(× 1)× 1>× 1