The source code to create an array without specifying type is given below. The given program is compiled and executed successfully.
// Rust program to create an array
// without specifying type
fn main(){
let arr1 = [5,10,15,20,25];
let arr2 = [5.1,10.2,15.3,20.4,25.5];
let arr3 = ["ABC","LMN","PQR","TUV","XYZ"];
println!("Array1: {:?}",arr1);
println!("Array2: {:?}",arr2);
println!("Array3: {:?}",arr3);
}
Program/Source Code:
The source code to create an array without specifying type is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created three arrays arr1, arr2, and arr3 with different data elements. After that, we printed the array elements.
need an explanation for this answer? contact us directly to get an explanation for this answer