C Programming Language

Misc Operator | Conditional Operator

Conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide which value should be assigned to the variable.

Syntax :
variable x =(expression) ? value if-true: value if-false

Example :

Output :

value of x is 5
*ptr is 5.
Value of x : 40
Value of y : 30