Logical OR Operator in C
Level 274 keystrokes
Uses logical OR (||) to give a discount to people under 18 or aged 65 and over; age is 65, so it prints "Discount applies".
C code
// The age to check is 651int age = 65;// || is true if at least one side is true: age < 18 is false, but age >= 65 is true2if (age < 18 || age >= 65) { // Runs because the whole condition is true and prints "Discount applies"3 printf("Discount applies\n");4}Output
Discount applies
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.
;× 2"× 2(× 2)× 2=× 2|× 2{× 1}× 1\× 1<× 1