Q:

Rust program to create a simple array

belongs to collection: Rust Arrays Programs

0

In this program, we will create an array of integer elements and then we will print the array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to create a simple array is given below. The given program is compiled and executed successfully.

// Rust program to create a simple array

fn main(){
   let intArr:[i32;5] = [5,10,15,20,25];
   println!("Array elements: \n{:?}",intArr);
}

Output:

Array elements:
[5, 10, 15, 20, 25]

Explanation:

Here, we created an array of 5 integer elements and printed them.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Rust Arrays Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Rust program to create an array without specifying... >>