Logical Or in C++
Level 269 keystrokes
Uses || to check whether day is 6 (Saturday) or 7 (Sunday); day is 6, so Weekend is printed.
C++ code
// Stores 6 in day; here 6 stands for Saturday1int day = 6;// || (logical OR) is true if at least one side is true// day == 6 is already true, so day == 7 is not even evaluated2if (day == 6 || day == 7) { // Prints Weekend because the condition is true3 cout << "Weekend" << endl;4}Output
Weekend
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<× 4;× 2"× 2|× 2(× 1)× 1{× 1}× 1