GitHub

Practice

Practice - 017

A program to explain COMPOUND IF

use text_io::scan;
fn main() {
practice17()
}
fn practice17() {
let num: i32;
println!("Enter a number:");
scan!("{}", num);
if num % 2 == 0 {
println!("{} is even", num);
} else {
println!("{} is odd", num);
}
}

Config

[package]
name = "practice"
version = "0.1.0"
edition = "2021"
[dependencies]
text_io = "0.1.12"

Result

Enter a number:
7
7 is odd
Enter a number:
12
12 is even
Previous
Practice - 016