First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

WAP to find greatest of three number using conditional operator

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer

{ Conditional Operator :

The conditional operator is also known as a ternary operator. The conditional statements are the decision-making statements which depends upon the output of the expression. It is represented by two symbols, i.e., '?' and ':'.

As conditional operator works on three operands, so it is also known as the ternary operator.

The behavior of the conditional operator is similar to the 'if-else' statement as 'if-else' statement is also a decision-making statement. }

Code ::

#include<stdio.h>
int main(){
  int a,b,c;
  int big;
   
  printf("Enter any three numbers: "); 
  scanf("%d%d%d",&a,&b,&c);


  if(a>b && a>c)
    big = a;
   else if(b>c)
    big = b;
   else
    big = c;
   
   printf("Largest number is: %d",big); 


  return 0;
}

Output::

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...