Welcome back, our latest lecture is about Selection.
The Selection is “a part of program algorithm that resulting a branching of the work flow and the flow of the algorithm is controlled by it’s condition”. or to put it simply, the “branch” of program workflow.
there is several type of selection on C Language:
- If
If is the most basic function on the Selection it has only a condition and one statement. if the program could fulfill the given condition, then the program will execute the statement, otherwise, nothing hapened, the program will skip the function. - If-else
similar to if structure but it has default statement which will executed when the condition isn’t fulfilled. - Nested If
usually happened when there is multiple condition to be checked. there is two type of nested if, first is “If under If” and “If-Else If” both of them have different syntax and slightly different meaning. while “If under If means there is condition check after the first selection get true result, “If-Else If” give another condition check when the first selection get false result. - Switch-Case
has similar function with “If-Else If”, but has more simple syntax, it usually used for Nested If condition that has lot of condition to check. this function really help to make the code easier to read. - “?:” operator
Similar with If-Else function, but it is used to return value.
That’s all for today, Have a good day~