0

What is the error at this nested loop ?

https://code.sololearn.com/czIJVgbE0Aue/?ref=app I want print this output 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999

29th Jan 2021, 1:12 PM
SH S
SH S - avatar
4 Respostas
+ 1
Check this how its working #include <iostream> using namespace std; int main() { int num, c; for (num = 1; num <10; num++) { for (c = 1; c <9; c++ ) { cout << num ; } cout << endl; } return 0; }
29th Jan 2021, 1:30 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Your code fails right at the first check ( num > 10 ) so doesn't even enter the loop. Remember that for loop runs till the time condition is true, not till the time it is false.
29th Jan 2021, 1:17 PM
Arsenic
Arsenic - avatar
0
Arsenic thank you i change it but i don’t know how i can print the above output
29th Jan 2021, 1:23 PM
SH S
SH S - avatar
0
Sizuna i understand it right now and thank you so much
29th Jan 2021, 1:40 PM
SH S
SH S - avatar