0
0
Goprogramming~10 mins

Operator precedence in Go - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to correctly calculate the result using operator precedence.

Go
result := 3 + 4 * [1]
Drag options to blanks, or click blank then click option'
A2
B5
C1
D0
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Adding 3 + 4 first, then multiplying by 5.
Ignoring operator precedence.
2fill in blank
medium

Complete the code to correctly evaluate the expression with mixed operators.

Go
result := (10 - 2) / [1] + 3
Drag options to blanks, or click blank then click option'
A4
B3
C1
D2
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Dividing before subtracting inside parentheses.
Adding before division.
3fill in blank
hard

Fix the error in the expression to get the correct result.

Go
result := 5 + 3 * 2 [1] 4
Drag options to blanks, or click blank then click option'
A-
B+
C*
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' instead of '-' causing wrong final result.
Ignoring operator precedence.
4fill in blank
hard

Fill both blanks to correctly compute the expression with operator precedence.

Go
result := (8 [1] 4) [2] 2
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' instead of '-' inside parentheses.
Dividing instead of multiplying after parentheses.
5fill in blank
hard

Fill all three blanks to correctly evaluate the complex expression.

Go
result := (6 [1] 2) [2] (3 [3] 1)
Drag options to blanks, or click blank then click option'
A+
B*
C-
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '-' instead of '+' in the first parentheses.
Using '-' instead of '/' in the second parentheses.
Adding instead of multiplying the two parentheses results.