Chapter 6

C# Programming: From Problem Analysis to Program Design · 12 exercises

Problem 1

Loops are needed in programming languages: a. to facilitate sequential processing of data b. to enable a variable to be analyzed for additional processing c. to process files stored on hard drives d. to allow statements to be repeated e. all of the above

6 step solution

Problem 2

To write a sentinel-controlled loop to compute the average temperature during the month of July in Florida, the best option for a sentinel value would be: a. 67 b. 1000 c. 100 d. "high temperature" e. none of the above

4 step solution

Problem 3

Which loop structure can only be used with a collection or array? a. foreach b. for c. while d. do ...while e. none of the above

6 step solution

Problem 4

If a loop body must be executed at least once, which loop structure would be the best option? a. foreach b. for c. while d. do ...while e. none of the above

4 step solution

Problem 5

If a loop body uses a numeric value that is incremented by three with each iteration through the loop until it reaches 1000 , which loop structure would probably be the best option? a. foreach b. for c. while d. do ...while e. none of the above

4 step solution

Problem 6

When used with a while statement, which jump statement causes execution to halt inside a loop body and immediately transfers control to the conditional expression? a. break b. goto c. return d. continue e. none of the above

4 step solution

Problem 7

pretest conditional expression that enables a loop to be executed as long as the counter variable is less than \(10 ?\) a. do while (c… # Which of the following is a valid C# pretest conditional expression that enables a loop to be executed as long as the counter variable is less than \(10 ?\) a. do while (counter \(<10\) ) b. while (counter \(<10\) ) c. foreach (counter in 10 ) d. none of the above e. all of the above

5 step solution

Problem 13

Which of the following represents a pretest loop? a. while b. do \(\ldots\) while c. for d. a and b e. a and \(c\)

5 step solution

Problem 14

If you intend to place a block of statements within a loop body, you must use ______ around the block. a. parentheses b. square brackets c. quotation marks d. curly braces e. none of the above

4 step solution

Problem 22

Write a for loop to display every third number beginning with 10 and continuing through 100.

5 step solution

Problem 23

Write a sentinel-controlled while loop that allows any number of temperatures to be entered. The average temperature should be calculated and displayed.

7 step solution

Problem 24

Create a loop body that generates random numbers between 25 and \(75 .\) Write a statecontrolled loop that adds all these randomly generated numbers until a value larger than 60 is generated. When the loop stops, display the number of acceptable generated values and the sum of those values.

4 step solution

Show/ page
Chapter 6 - C# Programming: From Problem Analysis to Program Design Solutions | StudyQuestionHub