+ 5
Why result is 8 ?
int y; for(int y = 2; y <= 6; y += 2) {} cout <<y;
2 Respuestas
+ 4
The result being 8 is coincidence, because the y that is being outputted has not been initialized before and therefore has some garbage value that was stored in that memory cell before.
The loop parameter y is only a local variable and doesn't actually affect the previously declared y, it has its own scope limited to the loop's body.
+ 3
Yes, I understand now