C Program to Find the Greatest Among Three Numbers

C Program to Find the Greatest Among Three Numbers

Here I shared C program to find the greatest among three numbers using a nested if-else statement and three numbers are entered by user.

For example, if user enter 3 numbers are 8,10 and 25 then the output will be:

Enter three numbers:
8
10
25
Maximum is 25





#include<stdio.h>
int main()
{
  int a,b,c;
   printf("\n Enter three numbers:");
   scanf("%d%d%d",&a,&b,&c);
  if(a>b)
  {
   if(a>c)
   {
    printf("Maximum is %d",a);
   }
  else
   {
    printf("Maximum is %d",c);
   }
  }
  else
   {
    if(b>c)
    {
    printf("Maximum is %d",b); 
    }
  else
   {
    printf("Maximum is %d",c);
   }
  }
 return 0;
}

NOTE: You have any problem in above C Program to Find the Greatest Among Three Numbers do not hesitate and write your problem in the comment box. I will support your problem.

Share this

0 Comment to "C Program to Find the Greatest Among Three Numbers"

Post a Comment