The source code to demonstrate the multiple (ladder) if-else statements is given below. The given program is compiled and executed successfully.
// Rust program to demonstrate the
// multiple (ladder) if-else statements
fn main() {
let mut num1:i32 = 95;
let mut num2:i32 = 105;
let mut num3:i32 = 75;
let mut large:i32=0;
if(num1>num2 && num1>num3)
{
large=num1;
}
else if(num2>num1 && num2>num3)
{
large=num2;
}
else
{
large=num3;
}
println!("Largest number is: {}",large);
}
Output:
Largest number is: 105
Explanation:
Here, we created 4 integer variables num1, num2, num3, and large. Those are initialized with 95, 105, 75, and 0 respectively. Then we checked and found the largest number using multiple if-else statements and printed the result.
Program/Source Code:
The source code to demonstrate the multiple (ladder) if-else statements is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created 4 integer variables num1, num2, num3, and large. Those are initialized with 95, 105, 75, and 0 respectively. Then we checked and found the largest number using multiple if-else statements and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer