The source code to find the EVEN numbers from the array is given below. The given program is compiled and executed successfully.
// Rust program to find the EVEN numbers
// from the array
fn main() {
let arr:[i32;5] = [13,18,23,14,12];
let mut i:usize = 0;
println!("Even numbers are: ");
while i<arr.len()
{
if arr[i]%2 == 0 {
print!("{} ", arr[i]);
}
i = i + 1;
}
}
Output:
Even numbers are:
18 14 12
Explanation:
Here, we created an array of the integer with 5 elements. Then we found the EVEN numbers from the array and printed the result.
Program/Source Code:
The source code to find the EVEN numbers from the array is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created an array of the integer with 5 elements. Then we found the EVEN numbers from the array and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer