Complete the code to declare an array of 5 integers initialized to zero.
let arr: [i32; 5] = [[1]; 5];
The syntax [value; size] creates an array with size elements, all set to value. Here, we want all zeros.
Complete the code to declare an array of 3 strings with specific values.
let fruits: [&str; 3] = ["Apple", [1], "Cherry"];
The array has three string slices. The middle element should be "Banana" to match the list.
Fix the error in the array declaration to specify the correct type and size.
let numbers = [1, 2, 3, 4, [1]];
The array has 5 elements, so the last element should be 5 to complete the sequence.
Fill both blanks to declare a mutable array of 4 floats initialized to 0.0.
let [1] arr: [[2]; 4] = [0.0; 4];
const instead of muti32 instead of float typeTo modify the array later, it must be mutable using mut. The type for floating-point numbers is f64.
Fill all three blanks to create an array of characters and print the third element.
let letters: [[1]; 4] = ['a', 'b', 'c', 'd']; println!("{}", letters[[2]]); // prints [3]
usize for array elementsThe array holds characters, so type is char. Indexing starts at 0, so the third element is at index 2, which is 'c'.
