Need help with grasping "for" and "while" loops.

No problem, like I said it's tricky starting out. Part of programming is figuring out these kinds of things. Eventually I promise you it will just 'click', until the next stage of learning!

The best way I can describe of when you increment (i++) is when you have completed all the tasks for the current loop cycle. If you have if-statements that do something based on the current cycle you can increment after all of those if statements, but this is problem specific of course.

For example, if you have a loop:

for(int i = 0; i < 100; i++) {
  if(i % 2 == 0) {
      print("Even");
  } else {
      print("Odd");
  }
  i++;
}    

You only need to increment at the end of the if statements, since you are done with what you are checking at each cycle. You would not have to put i++ in every if statement (in this case).

/r/learnprogramming Thread Parent