Test #1 Practice Questions


1. Using compound conditions (i.e., && || or !), write if statements that will classify a hurricane according to its wind speed, according to the following table:

Min speed
Max speed
Category
74
95
1
96
110
2
111
130
3
131
155
4
156

5


2. Redo the above problem using an if-else structure rather than compound conditions.

3. Write a switch statement that will output a message based on an integer variabled named option.  This switch is similar to what you might write if you had a switch statement associated with a menu.  The output messages should be:

4. Write a function named sumToN which takes one parameter n of type integer and returns the sum of integers from 1 to n. For example, sumToN(3) would return 6.

5. Write a function call as it would appear in main to call your sumToN function.

6. Write the prototype for your sumToN function.