ADVERTISEMENT
ADVERTISEMENT

Rust program to create a simple array

Rust | Array Example: Write a program to create a simple array.
Submitted by Nidhi, on October 19, 2021

Problem Solution:

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

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.

Rust Arrays Programs »



ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.