Print the EVEN numbers using Command Line Arguments
Rust Programming Language
Problem
In this program, we will find the EVEN numbers in Command Line Arguments and printed them.
Input
// Rust program to print the EVEN numbers// using Command Line Argumentsfn main(){let args = std::env::args();let mut num=0;let mut cnt=0;for arg in args {if cnt>0{num = arg.parse::<i32>().unwrap();if num%2==0{print!("{} ",num);}}cnt=1;}println!();}{codeBox}
Output
$ rustc CheckEven.rsExecute:$ ./CheckEven 10 15 2010 20{codeBox}
Explanation
In the main() function, we found the even numbers in Command Line Arguments and printed them.