Completion requirements
Read this chapter, which covers variables and arithmetic operations and order precedence in Java.
17. Counting Higher
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?)