Search C Program

Largest value of two variables - Conditional Operator

/*    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;
}

Related Post:
Find larger value between two variable
http://cbasicprogram.blogspot.in/2012/01/find-larger-value-between-two-variable.html

1 comment:

  1. please provide program to find largest of three variables using same conditional operator

    ReplyDelete