C Program to find the largest of three numbers using nested if


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


10 20 30 => 10

40 50 30 => 30

Example: How to find the largest of three numbers using nested if in c.

#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("Largest is :%d", a);
    } else {
      printf("Largest is :%d", c);
    }
  } else {
    if (b > c) {
      printf("Largest is :%d", b);
    } else {
      printf("Largest is :%d", c);
    }
  }

  return 0;
}

Output:

Enter three numbers :30 40 10                                                                                                                                       
Largest is :40