for loop stops prematurely, and shows no errors [closed]


I’m very new to programming, so please bear with me if the answer is obvious.

I’d also like to say that this is the second time I’m asking this question, my previous question was closed in less than hour. some people said that the code is completely fine, and judging by the documentations, yes it is, but for whatever reason it stops, and I have no idea how or why it stops when should be working, and this does affect my future workflow.

I tried to make a code that would generate a string of random numbers, the quantity and length of the string comes from the input. it started to stop.
I asked some of my friends (who are programmers but don’t know c++) for assistance and they told me to remove components from the code to find where the problem is, here’s the code in its shortened version which still stops

#include <iostream>

using namespace std;

int main()
    for (int i = 0; i < 10; i++)
        cout << i+1 << "- ";
        for (int j = 0; j < 100; j++)
            cout << 7;
        cout << endl;
    return 0;

the code stops at random intervals when executed, sometimes at the first line, sometimes somewhere in the middle, sometimes it finishes the whole task properly.

vs code with multiple iterations of the program stopping

taking previous criticism into account, here’s the program running on the debugger:

debug 1 debug 2 debug 3

I’m not sure what any of it means, but considering that the code works completely fine under the debugger every time and that the "The thread has exited with code 0 (0x0)." means that the thread is the one responsible for breaking the code sequence before it ends, but according to this thread ,I shouldn’t care?

I really don’t know what to do, I’ve been trying to fix it for about a week, I changed for() loops with while() loops, removed rand(), used proper namespaces instead cout, run as administrator …etc, and none of them worked. if I can’t use for loops then I can’t even code.

Source: Windows Questions C++