Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a for loop and I have an if statement that will check if the counter increases. How would I check that?

Below I have given an example of what I had in mind. Thanks for your help in advance.

What I have tried:

for (int i = 0; i < 8; i++){
   if ( **counter 'i' has increased** ){
      //do stuff
   }
}
Posted
Updated 29-Sep-18 19:38pm

1 solution

Add a variable outside the loop, and set it ti zero.
Inside the loop, compare it to the current value of i. If it is different, i has changed.
At the bottom of the loop, set it to i
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900