Search C Program | nimishsoft@gmail.com

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

4 comments:

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

    ReplyDelete
    Replies
    1. Various aspects of your query - https://www.computerscienceai.com/2018/02/c-program-to-accept-three-integers-as.html

      Delete
  2. For theory I referred from here , but finally found some programs about operators.

    ReplyDelete