0
0
Rustprogramming~10 mins

Scalar data types 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 declare an integer variable named num with value 10.

Rust
let num: [1] = 10;
Drag options to blanks, or click blank then click option'
Ai32
BString
Cbool
Df64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using String instead of an integer type.
Using bool which is for true/false values.
Using f64 which is for floating-point numbers.
2fill in blank
medium

Complete the code to declare a floating-point variable named pi with value 3.14.

Rust
let pi: [1] = 3.14;
Drag options to blanks, or click blank then click option'
Abool
Bi32
Cf64
Dchar
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using i32 which is for integers.
Using bool which is for true/false values.
Using char which is for single characters.
3fill in blank
hard

Fix the error in the code by choosing the correct scalar type for the variable flag.

Rust
let flag: [1] = true;
Drag options to blanks, or click blank then click option'
Ai32
Bbool
Cf64
Dchar
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using integer or floating types for boolean values.
Using char which is for characters.
4fill in blank
hard

Fill both blanks to declare a character variable letter with value 'A'.

Rust
let letter: [1] = [2];
Drag options to blanks, or click blank then click option'
Achar
B'A'
C"A"
DString
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using double quotes which create a string, not a char.
Using String type for a single character.
5fill in blank
hard

Fill all three blanks to declare a tuple data with an integer, a float, and a boolean.

Rust
let data: ([1], [2], [3]) = (42, 3.14, true);
Drag options to blanks, or click blank then click option'
Ai32
Bf64
Cbool
Dchar
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Mixing up types or using char incorrectly.
Using string types instead of scalar types.