0
0
Rustprogramming~5 mins

Arithmetic operators in Rust - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the '+' operator do in Rust?
The '+' operator adds two numbers together. For example, 2 + 3 equals 5.
Click to reveal answer
beginner
How do you perform multiplication in Rust?
Use the '*' operator to multiply two numbers. For example, 4 * 5 equals 20.
Click to reveal answer
intermediate
What is the result of 10 / 3 in Rust when using integer types?
When dividing integers, Rust performs integer division, so 10 / 3 equals 3 (the decimal part is dropped).
Click to reveal answer
beginner
What does the '%' operator do in Rust?
The '%' operator gives the remainder of a division. For example, 10 % 3 equals 1.
Click to reveal answer
intermediate
Can you use arithmetic operators with floating-point numbers in Rust?
Yes, you can use '+', '-', '*', and '/' with floating-point numbers (like f32 or f64). The operations work as expected with decimals. The '%' operator is not supported for floating-point types in Rust.
Click to reveal answer
What is the result of 7 + 5 in Rust?
A75
B2
C12
DError
Which operator gives the remainder of a division?
A%
B-
C+
D/
What happens when you divide two integers in Rust and the result is not whole?
AIt rounds up
BIt rounds down
CIt returns a float
DIt drops the decimal part
Which operator is used for multiplication in Rust?
A/
B*
C+
D-
Can you use the '+' operator with floating-point numbers in Rust?
AYes
BNo
COnly with integers
DOnly with strings
Explain how the '%' operator works in Rust and give an example.
Think about what is left after dividing one number by another.
You got /3 concepts.
    Describe what happens when you divide two integers in Rust and the result is not a whole number.
    Rust does not round but cuts off the decimal.
    You got /3 concepts.