 ### Find Largest Number b/w 3 Numbers using if-else-if

`if-else-if` statements are useful when we need to check multiple conditions within the same program. We can avoid the nesting of if-else blocks using if-else-if statement. The if statements are executed from top to bottom.

0 334 Technology | C-Programming
Tue Dec 25 , 2018

### Latest Article

• #### Alert Dialog Boxes in Javascript

In `if-else-if` statement, if one of the conditions controlling the `if` statement is `true`, the statement associated with that `if ` is executed. If none of the conditions is true, then the final `else` statement will be executed.

### Syntax

```if (condition1)
statement;
else if (condition2)
statement;
else if (condition3)
statement;
.
.
else
statement;
```

### Algorithm

```
Step 1: Start
Step 2: Declare variables x,y and z.
Step 3: Read variables x,y and z.
Step 4: If x>y
If x>z
Display x is the largest number.
Else
Display z is the largest number.
Else
If y>z
Display y is the largest number.
Else
Display z is the greatest number.
Step 5: Stop

```

In this `article` we will find the Largest Number among Three Numbers in C using if-else-if statement.

### Example

`Program to find the Largest Number among Three Numbers using if-else-if `

```

#include <stdio.h>

int main()
{
int a,b,c;
int largest;

printf("Enter three numbers :");
scanf("%d%d%d",&a,&b,&c);

if(a>b && a>c)
largest=a;
else if(b>a && b>c)
largest=b;
else
largest=c;

printf("Largest number is = %d",largest);

return 0;
}

```

### Outputs

```
Enter three numbers : 10 20 30
Largest number is = 30
```
```
Enter three numbers : 9 18 27
Largest number is = 27
```