Connect with one of the following accounts


Please wait while we redirect...

Views: 207   

You can write Ternary Operator in C Language using ?: Following example describes you where to use and how to use.
Lets say you have two variables a, b and you need to assign the values a or b to another variable let say result

In this situation you can use Conditional Operator like below

int result = (expression) ? a : b;

In the above code, if expression evaluates to true then result will be assigned with a otherwise with b.
For example your expression is (a > b) then you write code something like below

int result = (a>b) ? a : b;

This means result gets the max value of a and b

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News