+ 1
C++ Nested For Loop (Solved)
When I run this nested for loop on the code playground I get an output of WW When I run it on an ide I got off the playstore on my android it gives me 10 blank lines. what's the deal? for(int i;i<10;i++){ for(int h;h<10;h++){ cout << "W"; } cout << endl; }
2 Antworten
+ 1
since no value was assigned to them in the original code, garbage values are getting pulled from memory. sometimes they're smaller than 10, sometimes not so the output there will depend on the state of the memory of the device running the program
0
Ok, my own stupidity (like most of my problems)
I declared my variables, int I and int h, but i forgot to assign them a value.
i had
for(int i;)
Should have had
for(int i=0;)