Showing posts with label greatest among three numbers. Show all posts
Showing posts with label greatest among three numbers. Show all posts

Wednesday, May 16, 2018

C program to find the greatest among three numbers.


Program code
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Please input three numbers to find the greatest among them.\n");
scanf("%d%d%d",&a,&b,&c);
if ((a>b)&&(a>c))
printf("%d is the greatest among the given numbers.\n",a);
else if ((b>a)&&(b>c))
printf("%d is the greatest among the given numbers.\n",b);
else if ((c>a)&&(c>b))
printf("%d is the greatest among the given numbers.\n",c);
else
printf("All numbers are equal.\n");
getch();
}

Example of Output
Please input three numbers to find the greatest among them.
777
40
95
777 is the the greatest among the given numbers.