Blog Moved

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

Search This Blog

6 Aug 2012

C program to find Greatest Of Two Numbers Using Conditional Operator

/* 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 )

No comments:

Post a Comment