Here are some of the major concepts:
ifstatement checks a condition and will execute a task if that condition evaluates to true.
elsestatements make binary decisions and execute different code blocks based on a provided condition.
- We can add more conditions using
- Relational operators, including
!=can compare two values.
switchstatement can be used to simplify the process of writing multiple
else ifstatements. The
breakkeyword stops the remaining cases from being checked and executed in a switch statement.
Optional: Little Mac is an interplanetary space boxer, who is trying to win championship belts for various weight categories on other planets within the solar system.
Write a space.cpp program that helps him keep track of his target weight by:
- It should ask him what his earth weight is.
- Ask him to enter a number for the planet he wants to fight on.
- It should then compute his weight on the destination planet.
Here is the table of conversion: