Rust program to create a closure function to check given number is EVEN or ODD
// Rust program to create a closure function
// to check given number is EVEN or ODD
fn main()
{
let num1 = 10;
let num2 = 21;
let check_even = |n|
{
if n%2==0
{
println!("EVEN");
}
else
{
println!("ODD");
}
};
check_even(num1);
check_even(num2);
}
Output
EVEN
ODD
Table of Contents