1.

Explain Conditional operator with the help of an example.

Answer»

It is also known as Ternary operator as it requires 3 operands. It checks the condition, if it is evaluated as true it goes to True part else the False part. 

Syntax: 

Condition?True: False

Example:- Ans=(x>y?x:y);

If x=5 and y=3

As x>y i.e. 5>3 condition is true, Ans. is assigned the value of x, else Ans will get the value of y.



Discussion

No Comment Found

Related InterviewSolutions