Branching with if and else in C is straightforward.
To compile and run the program:
Note that in C, you need parentheses around conditions, and the braces are optional for single-statement blocks (though using them is generally recommended for clarity).
C doesn’t have a ternary if operator like ?:, but it does have the ternary conditional operator, which can be used for simple conditional expressions:
However, for more complex conditions, a full if statement is necessary.