I suggest you ...

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

20 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    anonymous shared this idea  ·   ·  Admin →

    3 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Mahmoud commented  · 

        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  · 

        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