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

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.