class JMM105 {
public static void main(
String args[]) {
int x = 6; int success = 0;
do {
switch(x) {
case 0: System.out.print("0"); x += 5; break;
case 1: System.out.print("1"); x += 3; break;
case 2: System.out.print("2"); x += 1; break;
case 3: System.out.print("3"); success++; break;
case 4: System.out.print("4"); x -= 1; break;
case 5: System.out.print("5"); x -= 4; break;
case 6: System.out.print("6"); x -= 5; break;
}
} while ((x != 3) || (success < 2));
}}
Output is coming as 61433 which matches with the answer Dan has given
but my doubt is --
After 614 is printed , x is changed to 3. So , the loop should stop
since the while condition of X!=3 is no longer satisfied.
Then how is the loop progressing even after that ?
Maybe i am missing some important point !!