

Flashcard on Accumulators and Sentinel Values
Flashcard
•
Hospitality and Catering
•
12th Grade
•
Practice Problem
•
Hard
Wayground Content
FREE Resource
Student preview

7 questions
Show all answers
1.
FLASHCARD QUESTION
Front
A(n) _____ value is a special value that cannot be mistaken as a member of the list, and signals that there are no more values to be entered. When the user enters the sentinel value, the loop terminates.
Back
sentinel
2.
FLASHCARD QUESTION
Front
The logic for calculating a sum of numbers generally requires the accumulator variable to be set to _____ otherwise the total may not be correct when the loop finishes.
Back
0
3.
FLASHCARD QUESTION
Front
A sentinel value is always included (summed) in the running total of an app that accumulates.
Back
False
4.
FLASHCARD QUESTION
Front
The best choice for a sentinel used in a program that sums the number of free throws made in an NBA playoff basketball game is 3 (assume Shaq is not playing).
Back
False
5.
FLASHCARD QUESTION
Front
-1 is not an ideal choice for a sentinel used to sum the number of days it is hot in the Sahara desert.
Back
False
6.
FLASHCARD QUESTION
Front
In the following program segment, which variable is the "loop control variable" (also known as the counter variable)? int a, r = 0, g = 0; while (r < 21) { g = r * 2; a += g; r++; } System.out.println("The sum is " + g);
Back
r
7.
FLASHCARD QUESTION
Front
In the following program segment, which is a VALID Java accumulator? int a, r, h = 1; g = 0; while (r < 21) { a = r * 2; g += a + h; r--; } System.out.println("The sum is " + g);
Back
g
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?