The conditional operator in C language, also known as the ternary operator, is a shorthand way of writing an if-else statement. It has the following syntax:
The condition is evaluated first, and if it is true, expression1 is evaluated and returned. If condition is false, expression2 is evaluated and returned. Here’s an example:
In this example, y will be assigned the value 1, because the condition (x > 5) is true. If the condition was false, y would be assigned the value 0.