Ternary Operator in C Language

This operator also known as conditional operator . It is similar to if-else statement.

Syntax of ? operator

There are three expressions in ? operator, Expression1, Expression2, and Expression3 .

The value of a ? expression is determined like this −

  • If Exp1 is true, then Exp2 is evaluated.
  • If Exp1 is false, then Exp3 is evaluated.

Example: write a program to find the grater between two number using ? operator.

OUTPUT