I suggest you ...

Flow control @ Last Question has a bug you need to correct

20 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Mahmoud commented  ·   ·  Flag as inappropriate

    The right answer is 13 not 12, because in the first while cycle the comparison happens before incrementing then i = 11 before go into the first loop, then it will be incremented again inside the first loop, now i = 12, in the next cycle the condition is not met, but the incrementing occurs instead, so finally i = 13...

  • jhansi commented  ·   ·  Flag as inappropriate

    Once see the code int i=10;
    while(i++<=10)
    { i++; }
    System.out.println(i);
    Actually the ans is:12
    But it displays ans is:13
    I need explanation in what way it would be 13.
    Please i need?

Feedback and Knowledge Base