/* C Program to find Greatest of Two Numbers Using Conditional Operator.. */
#include<stdio.h>
main()
{
int a,b,c;
printf("\n Enter two Numbers: ");
scanf("%d %d",&a,&b);
c=(a>b)?a:b; /* (a>b) is true then c=a else c=b */
printf("\n The Greatest number is : %d",c);
return(0);
}
Sample Output: ( using GNU GCC Compiler with Code Blocks IDE )
#include<stdio.h>
main()
{
int a,b,c;
printf("\n Enter two Numbers: ");
scanf("%d %d",&a,&b);
c=(a>b)?a:b; /* (a>b) is true then c=a else c=b */
printf("\n The Greatest number is : %d",c);
return(0);
}
No comments:
Post a Comment