double sum = 0, height = 2.0, stop =10, max = 50; int track = 0, num = 0; while
ID: 3773281 • Letter: D
Question
double sum = 0, height = 2.0, stop =10, max = 50;
int track = 0, num = 0;
while (num <= stop)
{
sum = sum + height * num;
if (sum <= max)
track++;
num++;
}
num, track
sum, track
track, sum
height, stop
double sum = 0, height = 2.0, stop =10, max = 50;
int track = 0, num = 0;
while (num <= stop)
{
sum = sum + height * num;
if (sum <= max)
track++;
num++;
}
Explanation / Answer
In the given code, the variable track is a counter and the variable sum is an accumulator.
Explanation:
The variable track is counter variable that is used to keep track of
number of sum values are found with condition sum <=max
in the while loop
The variable sum is an accumulator that accumulates the sum of
value of sum
and multiplication of num and height
(height *num)
The correct option is track , sum
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.