Skip to main content
Logo image

Section 9.5 if - else-if - else Statements

What if there are more than two cases, amongst which we’d like to distinguish?
Take a look at the following example:

admin.....open in new window

Figure 9.1.

Check Your Understanding Check Your Understanding

1.

Complete the following C program: After the user has entered a number, assign a score (use the variable "score" which has already been defined for this purpose) to the user input as follows: If the user enters a number less than 10 the score should be -1, if the user enters a number greater than 20 the score should be 1, and if the user enters a number between 10 and 20 the score should be 0. Then print the user’s score to the screen.

admin.....open in new window

When your program performs correctly you’ll be given a keyword to enter in Canvas.