Ask Question

considering that two variables counters and accumulators are important in loop design. What would be their purpose?

+3
Answers (1)
  1. 7 July, 18:16
    0
    Counters are used to run the loop.

    Accumulators are used to calculate and store the result.

    Explanation:

    In loops variables counters and accumulators are very important. The counter variable is used to increase the loop or move to the next iteration.

    The accumulator variable is used to calculate and store the result of an operation in the loop.

    For example:-

    int i=0;

    int sum=0;

    while (i<7)

    {

    sum=sum+i;

    i++;

    }

    In this while loop the counter variable is i and the accumulator variable is sum. Without the counter variable is not increased the loop will keep looping over the same value of i that is 0.

    In the loop the accumulator variable sum is used to calculate the sum of integers form i=0 to 6.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “considering that two variables counters and accumulators are important in loop design. What would be their purpose? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers