...

Boolean Operator Precedence

Just like in math, boolean operators have precedence rules. Remember how multiplication comes before addition?

In math: 1 + 2 x 2 is 5.

But parentheses can change precedence: (1 + 2) x 2 is 6.

The same applies to boolean operators:

  • && (AND) has higher precedence than || (OR)
  • A || B && C means A || (B && C)
  • (A || B) && C changes the meaning completely!

Tournament Discount System

Our gaming tournament offers a special discount for skilled players who are either very young or senior citizens: Level above 40, and age under 18 or over 65.

In other words: High skill level plus either youth or senior citizen status.

Your Task

The code sample already has the condition written, but it does not have correct precedence. Can you fix the condition by adding parentheses?

Loading...

Output (Console)