Question: Add an else You can only use an else statement in combination with an if statement. The else statement does not require a condition; its
Add an else
You can only use an else statement in combination with an if statement. The else statement does not require a condition; its corresponding code is simply run if all of the preceding conditions in the control structure are FALSE. Here's a recipe for its usage:
if condition
expr
else
expr
It's important that the else keyword comes on the same line as the closing bracket of the if part!
Both if statements that you coded in the previous exercises are already available to use. It's now up to you to extend them with the appropriate else statements!
Instructions
XP
Add an else statement to both control structures, such that
"Unknown medium" gets printed out to the console when the ifcondition on medium does not hold.
R prints out "Try to be more visible!" when the ifcondition on numviews is not met.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
