output???

Computer Science Level pending

class Test { public static void main(String [] args) { int x= 0; int y= 0; for (int z = 0; z < 5; z++) { if (( ++x > 2 ) || (++y > 2)) { x++; } } System.out.println(x + " " + y); } }

8 2 8 3 5 3 8 4

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Hasmik Garyaka
Oct 4, 2017

The cycle repeats 5 times. After each: x=1 y=1

x=2 y=2

x=4 y=2

x=6 y=2

x=8 y=2 || will return true if x>2 and y++ will not be computed

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...