Largest Among 3 Numbers - C Program

Program:
#include<stdio.h>
//#include<conio.h>
void main()
{
int a,b,c;
//clrscr();
printf("Enter the numbers:");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{    if(a>c)
        printf("%d is largest among %d,%d,%d\n",a,a,b,c);
    else
        printf("%d is largest among %d,%d,%d\n",c,a,b,c);
}
else if(b>c)
        printf("%d is largest among %d,%d,%d\n",b,a,b,c);
else
        printf("%d is largest among %d,%d,%d\n",c,a,b,c);
//getch();
}

Output:
nn@linuxmint ~ $ gcc cc4.c
nn@linuxmint ~ $ ./a.out
Enter the numbers:5
3
2
5 is largest among 5,3,2nn@linuxmint ~ $

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...