go to previous page   go to home page   go to next page hear noise highlighting

Answer:

21


Counting Down

Recall the general form of a for:

for ( initialize ; test ; change )
  loopBody ;

The change can be any statement. It can, for example, decrease the control variable, as in this example:

int count;

for ( count = 10; count >= 0; count--  )  
{
  System.out.println( "count is: " + count ); 
}
System.out.println( "\nDone with the loop.\nCount is now" + count);

The expression count-- decrements count by one.




     

QUESTION 10:

Would the output of this program be any different if the expression count-- were changed to --count   ?


go to previous page   go to home page   go to next page