Conditional Operator in C

It is also called a ternary operator. It takes three operands. The general form of the conditional operator is exp1?exp2:exp3; Where exp1, exp2, and exp3 all are expressions. expression one is evaluated first, and if the value of exp1 is non-zero or 1 then expression 2 is evaluated else expression 3 is evaluated. This operator is an alternative to the if-else conditional statement. It seems like a shorthand for an if-else block.

Example:

#include<stdio.h>
int main()
{
    int a,b,c;
    printf("Enter the values of a and b:");
    scanf("%d %d",&a,&b);
    c=(a>b)?a:b;
    printf("The Biggest Number is : %d ",c);
    return 0;
}

Output:

Enter the values of a and b:12
13
The Biggest Number is : 13