0
can someone explain this ?
int main() { int x=3; while(x++<10){ } cout<<x; //output 11 return 0; }
1 Answer
+ 11
The 'cout' is outside the loop, 'x++ < 10' becomes false (and loop stops) at '10 < 10', but the post-increment is adding 1 after that line of code so you end up having 11.
post-increment adds 1 after the instruction while pre-increment adds immediately/before.



