28.1k views
2 votes
This variable controls the number of times that the loop iterates. A. Counter variable B. Loop control variable C. Running total D. Decrement variable

User ChyBy
by
3.9k points

1 Answer

5 votes

Answer:

B) Loop control Variable

Step-by-step explanation:

When programming, A loop control variable is used to control the number of iterations for a program loop. By convention programmers love to call this variable counter, i, j, n etc. The control variable when defined will determine the number of times a loop will execute. See the example bellow in C++ where we use a for loop to print the word "Hello" 5 times

#include <iostream>

using namespace std;

int main()

{

for(int counter = 0; counter<5; counter++){

cout<<"Hello"<<endl;

}

return 0;

}

In this code snippet, the control variable is called counter and the condition is that counter will run from 0 to 4. So we get the world Hello printed five times

User W Dyson
by
4.7k points