-if else
-switch case
-?(ternary operator)
first thing what is decision/branch?
Decision is a condition which has structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
If else:
If-else can be used for any kinds of data types. The if statement checks whether the text condition/statements inside parenthesis () is true or false. If the statements is true, then condition/s inside the body of if statement is executed but if the statements is false, statement/s inside body of if is ignored. For example: Click to enlarge the pic!Switch Case
Switch case statements mostly used when we have number of conditions and we need to perform a different tasks for each. Switch case can be only used for char and integer. Look at this example carefully to understand it.
Click to enlarge the pic
?: (Ternary Operator):
Basically, the principle of ternary operation is similar to if-else. The difference is ternary operator can’t be nested and it’s the shorter version of if-else. Ternary operator can be written like this:condition ? value_if_true : value_if_false
Let’s take a look of the example to understand about it better.
Click to enlarge the pic
- First, ternary operator signed with “?:” symbol.
- How to read the condition? The working hours is 8 hours if the day that you input is less than six day and 2 hours if the day that you input is six or more than six.


