0
Can someone explain this. How it works .
int main() { int x=3; while(x++<10){ x+=2; } cout<<x; //Output 13 }
5 Respostas
+ 8
3
3<10 true // first check then increment
3++ => 4
4+2 => 6
6<10 True
6++ => 7
7+2 => 9
9<10 True
9++ => 10
10+2 => 12
12 < 10 False
12++ => 13
hence x is 13
+ 7
Ani Jona 🕊 thanks for the correction
+ 2
In the while loop, you are adding 3 on each loop, the x++<10 means that x will be checked and get incremented by 1. When x = 9, it will be true, then x will become 10, then add 2 (x=12). In the last loop, x get incremented by 1(x=13), but the loop stops.
+ 1
ah so... Thanks
0
how x will become 10 ?