New course! Every coder should learn Generative AI!
Try a free lesson0
Why is this code skipping the "for" part
1 Answer
+ 3
In C++, the behavior of using an uninitialized variable is undefined, so it can have any value, which may not be what you expect.
To fix this issue, you should initialize i to 0 in the for loop declaration