# Rust program to demonstrate the nested if-else statements

Rust | Nested if-else statements example: Given three integer variables, we have to find the largest number among them.
Submitted by Nidhi, on October 03, 2021

Problem Solution:

Here, we are creating three integer variables and then find the largest number among them using nested if-else statements.

Program/Source Code:

The source code to demonstrate the nested if-else statements is given below. The given program is compiled and executed successfully.

```// Rust program to demonstrate the
// nested 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)
{
if(num1>num3)
{
large=num1;
}
else
{
large=num3;
}
}
else if(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 found the largest number using nested if-else statements and printed the result.