The source code to find the Even/Odd using the if let statement is given below. The given program is compiled and executed successfully.
// Rust program to find the Even/Odd
// using the if let statement
fn main()
{
let num: i32 = 23;
let result = if let 0=num%2{
"Even"
}
else{
"Odd"
};
println!("Number is: {}",result);
}
Output:
Number is: Odd
Explanation:
Here, we created a variable num of i32 type with the initial value of 23. Then we checked variable num contains an EVEN or ODD number using the if let statement. After that, we printed the result.
Program/Source Code:
The source code to find the Even/Odd using the if let statement is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a variable num of i32 type with the initial value of 23. Then we checked variable num contains an EVEN or ODD number using the if let statement. After that, we printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer