A good answer might be:

No — since for statements can be used to implement any kind of loop it must be that the change part is very flexible.

Small Change

The change part could be a very complicated statement, although it is best if it is kept small and understandable. Here is almost the same loop as in the previous example, but now the control variable is incremented by two. Try to predict the output before you run the program. (This is good practice for midterms and finals.)

int count;
for ( count = 0; count < 7; count = count + 2 )  
{
  System.out.println( "count is: " + count ); 
}
System.out.println( "\nDone with the loop.\nCount is now" + count);

Here is a JavaScript version of this loop.




The change to count is done at the bottom of the loop body. This means that the last value that count gets is the first one that fails the test count < 7.

QUESTION 7:

Show each of the following sequences (as a sequence of numbers):

start at 0, count upward by 1's__, __, __, __, __, __, __, . . .
start at 0, count upward by 2's__, __, __, __, __, __, __, . . .
start at 1, count upward by 2's__, __, __, __, __, __, __, . . .