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

Answer:

Put a copy of statements 3 and 4 at the end.


Counting Higher

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?)


QUESTION 18:

What does the following assignment statement do:

sum = 2*sum ;

(What are the two steps, in order?)


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