Tagged: understand ternary operator

The Conditional Operator in C Programming Language 46

The Conditional Operator in C Programming Language

The conditional operator in C is also known as ternary operator. It is called ternary operator because it takes three arguments. The conditional operator evaluates an expression returning a value if that expression is true and different one if the expression is evaluated as false. Syntax for conditional operator in C:

If the condition is true, result1 is returned else result2 is returned. C Conditional Operator Examples:

Program in C using Conditional Operator

Output: 10 In the above program, if the value of a is less than b then the value of a would be assigned to...