If Statements
One way to control and make decisions in programming is the use of if statements
.
The code above only executes the message: No school today!
, if the day is either Saturday or Sunday.
If the day variable was set to something other than Saturday or Sunday, this program would have no output.
How to Format an If Statement
As long as the boolean condition within the parentheses evaluate to
true
the code within the code block will execute.
Last updated