What is a Conditional Operator?

Conditional Operator (?:) is also known as Ternary Operator which perform operations on three operands.

Syntax: ExpressionA? expressionB:expressionC

Here expressionA is evaluated first if it is true then expressionB will be evaluated where and if the value of expression1 is false then expressionC will be evaluated.

Eg: int a, b,c;

c=a>b? a:b;

In above example if value of a is greater than b then value of a will be stored in c else if value of b is greater than value of a then value of b will be stored in c.

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.