Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A student wrote the following code for a guessing game. Line 1: secretNumber RANDOM (1, 100) Line 2: win ← false Line 3: REPEAT UNTIL (win) Line 4: ( Line 5: DISPLAY ("Guess a number.") Line 6: guess INPUT ( ) Line 7: IF (guess = secretNumber) Line 8: ( Line 9: DISPLAY ("You got it right!") Line 10: } Line 11: Line 12: Line 13: ( ELSE IF (guess > secretNumber) Line 14: ( Line 15: DISPLAY ("Your guess is too high.") Line 16: } Line 17: ELSE Line 18: ( Line 19: DISPLAY ("Your guess is too low.") Line 20: } Line 21: } Line 22: } While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction win true somewhere in the code. Where could win true be inserted so that the code segment works as intended? Between line 6 and line 7 Between line 9 and line 10 Between line 20 and 21 Between line 21 and 22

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 7E: (Simulation) Write a program to simulate the roll of two dice. If the total of the two dice is 7 or...
icon
Related questions
Question
Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
A student wrote the following code for a guessing game.
Line 1:
secretNumber RANDOM (1, 100)
Line 2: win ← false
Line 3:
REPEAT UNTIL (win)
Line 4: (
Line 5:
DISPLAY ("Guess a number.")
Line 6:
guess INPUT ( )
Line 7:
IF (guess = secretNumber)
Line 8:
(
Line 9:
DISPLAY ("You got it right!")
Line 10:
}
Line 11:
Line 12:
Line 13:
(
ELSE
IF (guess > secretNumber)
Line 14:
(
Line 15:
DISPLAY ("Your guess is too high.")
Line 16:
}
Line 17:
ELSE
Line 18:
(
Line 19:
DISPLAY ("Your guess is too low.")
Line 20:
}
Line 21:
}
Line 22: }
While debugging the code, the student realizes that the loop never terminates. The student plans to insert
the instruction win true somewhere in the code. Where could win true be inserted so that
the code segment works as intended?
Between line 6 and line 7
Between line 9 and line 10
Between line 20 and 21
Between line 21 and 22
Transcribed Image Text:Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A student wrote the following code for a guessing game. Line 1: secretNumber RANDOM (1, 100) Line 2: win ← false Line 3: REPEAT UNTIL (win) Line 4: ( Line 5: DISPLAY ("Guess a number.") Line 6: guess INPUT ( ) Line 7: IF (guess = secretNumber) Line 8: ( Line 9: DISPLAY ("You got it right!") Line 10: } Line 11: Line 12: Line 13: ( ELSE IF (guess > secretNumber) Line 14: ( Line 15: DISPLAY ("Your guess is too high.") Line 16: } Line 17: ELSE Line 18: ( Line 19: DISPLAY ("Your guess is too low.") Line 20: } Line 21: } Line 22: } While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction win true somewhere in the code. Where could win true be inserted so that the code segment works as intended? Between line 6 and line 7 Between line 9 and line 10 Between line 20 and 21 Between line 21 and 22
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning