Branching with if and else in Objective-C is straightforward.
To run the program, compile and execute it:
Note that in Objective-C, you need parentheses around conditions, and braces are required for multi-line blocks. Single-line blocks can omit braces, but it’s generally recommended to always use them for clarity and to prevent errors.
Objective-C does have a ternary operator (?:), which can be used for simple conditional expressions. However, for more complex conditions, a full if statement is often clearer and more maintainable.