Int i = 1; while(i++<=1) { i++; system.out.print(i + "" "" ); } system.out.print(i);
Answers
Answer:
Well the answer is 3 4
Explanation:
int i = 1;
while (i++<=1){...}
The while statements checks if 'i' is lesser or equal to 1...
now 'i' is 1, so the interpreter hops inside the loop.
But the while loop's condition has i++ in it, so 'i' gets incremented after the interpreter goes inside the loop.
'i' is now 2
i++; so 'i' is now 3
S.O.P(i + " "); displays "3 "
next the interpreter goes back to check the condition of the while loop.
while (i++<=1) {...}
as 'i' is 3, the condition is false, BUT the condition also contains the statement i++, so i gets incremented by 1, making 'i' as 4
After the loop ends,
S.O.P(i); display "4"
So the total result is "3 4"
Writing i++, the interpreter will first execute the current statement, then it will increment i by 1
I hope you understood my explanation, English is not my primary language.
Answer:
3 4
this is the answer
please mark me the brainliest