[Solved] Why does this nested loop output starts at 8 and 18?


Are you sure that it isn’t starting at i = 2 and j = 2? You are running this loop so many times that your console output may not show that it starts at 2,2, even though it does. Try setting a breakpoint in the second for loop, I think you’ll see it is starting at 2, 2. That’s because the buffer size is too small.

Here’s what you can do:

  • Run your project.
  • Right-click on the title bar-> Properties-> Layout.
  • Set your height to something really large.

You can refer to this question for more.

4

solved Why does this nested loop output starts at 8 and 18?