C program to find Greatest of two Numbers Using Conditional Operator..
PROGRAM:
PROGRAM:
#include<stdio.h>
main()
{
int a,b,c;
printf("\n Enter two Numbers: ");
scanf("%d %d",&a,&b); /* (a>b) is true then c=a else c=b */
c=(a>b)?a:b;
printf("\n The Greatest number is : %d",c);
return(0);
}
Sample Output: ( using GNU GCC Compiler with Code Blocks IDE )
Enter two Numbers: 10 20
The Greatest Number is : 20
C++ program to Find Largest Number among three numbers
ReplyDeleteThanks for this code, it's very simple and easy.