Question: In the following program segment, which variable is the loop control variable (also known as the counter variable) and which is the accumulator? int a,

In the following program segment, which variable is the loop control variable (also known as the counter variable) and which is the accumulator? 

int a, x = 0, y = 0;
while (x < 10)
{
 a = x * 2;
 y += a;
 x++;
}
System.out.println("The sum is " + y);

Step by Step Solution

3.43 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The Python for statement iterates over the members of a sequence in order executing the block each ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Starting Out With Java From Control Structures Questions!