In this tutorial, you will learn about the Conditional/Ternary Operations in C and their usage and examples.
Conditional/Ternary Operations in C with Example
Conditional/Ternary operation returns one value if the condition is true and returns another value if the condition is false.
Conditional/Ternary Operation a simplified if the condition that is written in one line.
Syntax of Conditional/Ternary Operations
(Condition? true_value: false_value);
(a == 1) ? 20: 30
Explanation
If a = 1, then return 20, else return 30.