C Program to find largest of three numbers using nested if


In this program, You will learn how to find largest of three numbers using nested if in C.


10 20 30 => 10

40 50 30 => 30


Example: How to find largest of three numbers using nested if in C

Run it Now
#include<stdio.h>

int main() {

   int a, b, c;

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

   if (a > b) {
       if (a > c) {
           printf("\nLargest is :%d", a);
       } else {
           printf("\nLargest is :%d", c);
       }
   } else {
       if (b > c) {
           printf("\nLargest is :%d", b);
       } else {
           printf("\nLargest is :%d", c);
       }
   }

   return 0;
}

Output:

Enter Three numbers :10 20 30
Largest is :30