C Program To Find Max Number Among Given Three Number Using If/Else Statements

/* C Program to find Largest of Three numbers using Else If Statement */
#include <stdio.h>
int main()
{
 int a, b, c;
 printf("Please Enter three different values\n");
 scanf("%d %d %d", &a, &b, &c);
 if (a > b && a > c)
  {
   printf("\n%d is Greater Than both %d and %d", a, b, c);
  }
 else if (b > a && b > c)
  {
   printf("\n%d is Greater Than both %d and %d", b, a, c);
  }
 else if (c > a && c > b)
  {
   printf("\n%d is Greater Than both %d and %d", c, a, b);
  }
 else
  {
   printf("\nEither any two values or all the three values are equal");
  }
 return 0;
}

Output:

Please Enter three different values
12
4
6
12 is Greater Than both 4 and 6
Sharing Is Caring

Leave a Comment