Put a copy of statements 3 and 4 at the end.
The following fragment:
int count = 0; // statement 1 System.out.println( count ) ; // statement 2 count = count + 1; // statement 3 System.out.println( count ) ; // statement 4 count = count + 1; System.out.println( count ) ;
prints out
0 1 2
The statement
count = count + 1;
increments the number in count. Sometimes programmers call this "incrementing a variable" although (of course) it is really the number in the variable that is incremented.
What does the following assignment statement do:
sum = 2*sum ;
(What are the two steps, in order?)
What does the following assignment statement do:
sum = 2*sum ;
(What are the two steps, in order?)