Practice
Practice - 009
A program to explain conditional expression, which can be alternative to a ternary operator
use text_io::scan;
fn main() { practice9()}
fn practice9() { let a: i32; let b: i32;
println!("Enter the values of a,b: (with a space in between)"); scan!("{} {}", a, b);
let largest = if a > b { a } else { b };
println!("Largest number: {}", largest);}
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)3 5Largest number: 5
Enter the values of a,b: (with a space in between)20 10Largest number: 20