0
0
Rustprogramming~10 mins

Operator precedence in Rust - 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 of 3 + 4 * 2.

Rust
let result = 3 + 4 [1] 2;
println!("{}", result);
Drag options to blanks, or click blank then click option'
A+
B/
C-
D*
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' instead of '*' causes addition to happen first, changing the result.
2fill in blank
medium

Complete the code to correctly calculate the result of (3 + 4) * 2.

Rust
let result = (3 + 4) [1] 2;
println!("{}", result);
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' instead of '*' ignores the multiplication step.
3fill in blank
hard

Fix the error in the expression to correctly compute 10 - 3 * 2 + 1.

Rust
let result = 10 [1] 3 * 2 + 1;
println!("{}", result);
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' instead of '-' changes the meaning of the expression.
4fill in blank
hard

Fill both blanks to correctly calculate the expression: 8 + 6 / 3 - 2.

Rust
let result = 8 [1] 6 [2] 3 - 2;
println!("{}", result);
Drag options to blanks, or click blank then click option'
A+
B-
C/
D*
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Swapping '+' and '/' changes the calculation order and result.
5fill in blank
hard

Fill all three blanks to correctly compute the expression: 5 + 4 * 3 - 6 / 2.

Rust
let result = 5 [1] 4 [2] 3 [3] 6 / 2;
println!("{}", result);
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 last blank changes the final result.