Answer:
The program will print out:
value is: 5 value is: 15
A Sequence that Counts
Look at this program fragment:
int count = 0; // statement 1 System.out.println( count ) ; // statement 2 count = count + 1; // statement 3 System.out.println( count ) ; // statement 4
Here is how the program works:
- Statement 1 puts 0 into
count. - Statement 2 writes out the 0 in
count. - Statement 3 first gets the 0 from
count, adds 1 to it, and puts the result back incount. - Statement 4 writes out the 1 that is now in
count.
When the fragement runs, it writes:
0 1
QUESTION 17:
Think of a way to write 0, 1, and 2.