If Statements
Last updated
Last updated
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.
As long as the boolean condition within the parentheses evaluate to
true
the code within the will execute.