Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

25 Jul 2012

C program to find Greatest of two Numbers Using Conditional Operator

C program to find Greatest of two Numbers Using Conditional Operator..

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


1 comment: