...

/

Solution Review 1: Check If Even or Odd

Solution Review 1: Check If Even or Odd

This lesson gives a detailed solution review of the challenge in the previous lesson.

We'll cover the following...

Solution:

Press + to interact
fn test(_a:i32) {
// check divisibility by 2
if _a % 2 == 0 { // execute if divisible
println!("Number {} is even", _a);
}
else { // execute if not divisible
println!("Number {} is odd", _a);
}
}

Explanation

Note: The statement ...

svg viewer