GitHub

Practice

Practice - 020

A program to explain NESTED IF (To find maximum among three numbers)

use text_io::scan;
fn main() {
practice20()
}
fn practice20() {
let a: i32;
let b: i32;
let c: i32;
println!("Enter the values of a,b,c: (with a space in between)");
scan!("{} {} {}", a, b, c);
let max = if a > b {
if a > c {
a
} else {
c
}
} else {
if b > c {
b
} else {
c
}
};
println!("Larger number: {}", max);
}

Config

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

Result

Enter the values of a,b,c: (with a space in between)
12 45 6
Larger number: 45
Previous
Practice - 019