GitHub

Practice

Practice - 018

A program to explain IF ELSE (find larger number among given two numbers)

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

Config

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

Result

Enter the values of a,b: (with a space in between)
7 5
Larger number: 7
Enter the values of a,b: (with a space in between)
20 4
Larger number: 20
Previous
Practice - 017