Largest value of two variables - Conditional Operator

Below is C program to Largest value of two variables - Conditional Operator.

Program:

/*Find largest value between two variables - single line - Conditional Operator*/

#include<stdio.h>
int main()
{
 int a,b,d;

 printf("Type values of A and B : ");
 scanf("%d %d",&a,&b);
 d=(a>=b?a:b);
 printf("Greatest value : %d",d);
 return 0;
}

No comments:

Post a Comment