Course of Raku / Advanced / Operators / Review of operator behaviour / Exercises

Force the order

Problem

The ** operator binds tighter than +, so 2 ** 3 + 1 is read as (2 ** 3) + 1, which is 9. Add parentheses to override that precedence, making the addition happen first, and print the result.

Example

The program prints:

16

Solution

See the solution

Course navigation

Review of operator behaviour   |   Solution: Force the order