Branching with if and else in D is straightforward.
To run the program:
Note that you don’t need parentheses around conditions in D, but the braces are required.
D does not have a ternary if operator, so you’ll need to use a full if statement even for basic conditions. However, D provides an alternative in the form of the ?: operator, which can be used for simple conditional expressions.