answersLogoWhite

0


Best Answer

The for loop uses a counter or an index variable to loop through the statements. This variable is used through the loop, changed and finally compared with the loop condition for consideration of the loop's next cycle.

The variable(s) used inside the for loop for comparison (with the mentioned condition) and increment/decrement is know as the index variable.

for example (Java) :

for(int i=1; i<5; i++){

...

}

in this example, integer 'i' is the index variable.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the index variable in the for loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

A variable declared inside the for loop control cannot be referenced outside the loop?

Yes. A variable declared inside the loop is a local variable for the code block enclosed by the {} statements of the for loop. The variable will not be available to be used by any code outside the code block.


A countdown loop operates by the loop control variable?

decremented


A loop control variable that is incremented a specific number of times is known as?

A loop control variable is widly known as a "counter".


Does 'for loop' works in C plus plus?

In C++, a for loop is structured as follows: for( int index = 0; index &lt; 10; ++i ) { //do something }


What is the last step in a loop usually?

increment the loop control variable


Compare While with for Statements?

The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.


When a VBScript loop control variable is not altered during loop execution what kind of loop may result?

An infinite loop.


Which loop is specifically designed to initiate test and increment a counter variable?

for loop


Difference between fixed loop and variable loop?

Fixed loop: this is the loop where the number of iterations are known. Variable loop: Here the number of iterations are not known Example for a variable loop. The pseudocode for variable whille loop begin character cchoice display"enter the choice" accept cchoice while(cchoice='y') begin //execute the statements end end Rkarthikeyan


What is the value of count after execution of the for-loop?

The value of count should be more than max range of the for-loop. e.g. for (index=0;index&lt;n;index++) ....In this case the count (i.e. index) would be more than "n" which is max-range.


What is a C programming to calculate the sum of 1-2-3-4-5 and so on using while loop a for loop and a do while loop?

#include using std::cout;using std::endl;int main(){int number(1);cout number;//using loop forint sum(0);for(int i(1); i


Why you need a for loop when you have already while loop or do while loop?

We need a for loop because the while and do-while loops do not make use of a control variable. Although you can implement a counter inside a while or do-while loop, the use of a control variable is not as self-evident as it is in a for loop. Aside from the use of a control variable, a for loop is largely the same as a while loop. However, it is quite different to a do-while loop, which always executes at least one iteration of the loop before evaluating the conditional expression. In a for and while loop, the conditional expression is always evaluated before entering the loop, which may result in the loop not executing at all.