Problem 1
State whether the following are true or false. If the answer is false , explain why. a. The default case is required in the switch selection statement. b. The break statement is required in the default case of a switch selection statement to exit the switch properly. c. The expression \((x>y 88 ay\) is true or the expression \(a
Problem 3
Find the error(s) in each of the following code segments and explain how to
correct it (them).
a. \(x=1 ;\)
while \((x<10)\)
\(x++;\)
\\}
b. for \((y=.1 ; y !=1 . \theta ; y+=.1)\)
cout \(<
Problem 4
Find the error(s) in each of the following:
a. For \((x=100, x>=1, x++)\) cout \(<
Problem 5
Write a program that uses a for statement to sum a sequence of integers. Assume that the first integer read specifies the number of values remaining to be entered. Your program should read only one value per input statement. A typical input sequence might be 5100200300400500 where the 5 indicates that the subsequent 5 values are to be summed.
Problem 6
Write a program that uses a for statement to calculate and print the average of several integers. Assume the last value read is the sentinel 9999 A typical input sequence might be 10811799999 indicating that the program should calculate the average of all the values preceding 9999
Problem 7
include
Problem 8
Write a program that uses a for statement to find the smallest of several integers. Assume that the first value read specifies the number of values remaining and that the first number is not one of the integers to compare.
Problem 9
Write a program that uses a for statement to calculate and print the product of the odd integers from 1 to 15.
Problem 12
Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks \((*)\) should be printed by a single statement of the form cout \(<<\stackrel{*^{\prime}}{*}\) (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.]
Problem 14
A mail order house sells five different products whose retail prices are: product \(1 \$ 2.98,\) product \(2 \$ 4.50,\) product \(3 \$ 9.98,\) product \(4 \$ 4.49\) and product \(5 \$ 6.87 .\) Write a program that reads a series of pairs of numbers as follows: a. product number b. quantity sold Your program should use a switch statement to determine the retail price for each product. Your program should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.