Topics:
Switch statement, Logical
Operators and Conditional Operator
Learning Outcome:
At the end of this lab, student should be able:
1.
Use switch statement to specify alternative paths of program’s execution.
2.
Use logical operators to combine Boolean expressions.
3. Use conditional operators
for concise and elegant code for decision making.
For this Lab, we need to use
switch statement, logical operators and conditional operators depends on the
question.
For certain question, we need to use switch statement to
determine days, and also months.This is example of using switch statement to
determine months,
Conditional operators can be used when we wanted to combine
two Boolean expression;
It gives us 3 options,other than number 0,1 and 2 it will
give us error message.
It is important to use the correct notation,such as the
bracket () for the Boolean expressions,: for else if, and also the ?.
No comments:
Post a Comment