C++ if and switch statements

If statements let you make choices in your programs. For example, here's an if statement that chooses whether or not to give a player an award based on how many points they earned in a level:



Elif statements allow you to link several if statements together. When you use elif statements, only one branch will be executed, and the rest will be skipped. An else statement can be added to the end to handle all other cases that don't fit the other tests. For example, in this code, if a user types the number 50, they will be told to wear a sweater, but NOT told to wear a tshirt or flip flops, even though 50 is less than both 60 and 80:



If statements work with both number inputs and text, like in this example: