Conditional/Ternary Operators in C

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


If a = 1, then return 20, else return 30.


Back to: Learn C Programming > Expression and Operators in C

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.