C Program to Find the Greatest Among Three Numbers

In this example, we learn how to write C program to find the greatest among three numbers. Write a c program to input the three numbers from the user and perform operations to find the largest among three numbers. Logic to find the greatest among three numbers.

C Program to Find the Greatest Among Three Numbers

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;
}

You have any problem do not hesitate and write your problem in the comment box. I will support your problem.

Happy Coding 😊

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form