Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (anonymous):

1. In a for loop, the iterator variable is used for keeping track of what? (Select the best answer.) (Points : 1) How many for loops are running in a program The number of objects in a program The names of the variables used in a program How many times the for loop has iterated

OpenStudy (anonymous):

i really need help

OpenStudy (gavlois1):

In a for loop of the format: for(k=0;k>5;k++) { //Code; } You use the iterator variable k to find out how many times the loop will run. You can count this by increasing k by 1 (k++) each time the loop runs until it reaches a value less than 5.

OpenStudy (anonymous):

Yes that is the correct idea so the last answer 'How many times the for loop has iterated' is the correct response however in the above code the loop will never execute because k is never greater than 5. I suspect this is just a typo and if '>' was changes to '<' then it would indeed run 5 loops when k was equal to 0,1,2,3 and 4.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!