Sunday, August 31, 2014

Write a program to find the greatest of the three numbers entered through the keyboard using conditional operators.


Code

#include <stdio.h>
#include <conio.h>
int main()
{
int a,b,c;
printf("enter 3 numbers (a,b,c)to find greatest no: ");
scanf("%d%d%d",&a,&b,&c);
(a>b&&a>c)?printf("a is greatest"):((b>a&&b>c)?printf("b is greatest"):printf("c is greatest"));

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

find greatest number using conditional operator

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact