how do we write a for loop which will produce the following output using two nested for loops
1
22
333
4444
55555
Printable View
how do we write a for loop which will produce the following output using two nested for loops
1
22
333
4444
55555
This is a simple idea. Have you tried thinking about double for loops? You will need it here. I don't want to tell you the solution, because it is better to learn.Code:for(...;...;...) {
for(...;...;...) {
// some print statement
}
}
My question is what the hell have you been up to in the past week that you ask the same question with the same lack of effort?
http://cboard.cprogramming.com/cplus...need-help.html
we'll i have tried this one but it seems that there is too many errors
Code:
#include <iostream>
int j,i,max;
main()
{
for (i=1;i<max;i++)
{
for(j=i;j>0;j--)
{
printf("%d",i);.
}
printf("\n",);
}
system("pause");
}
This must be a troll.
Perhaps you should practice getting ONE loop to compile first, before trying two.
Say output
1
2
3
4
5
Surely you could do that?
Maybe?
If you're supposed to be C++ then copying and pasting someone else's program is not going to earn you any brownie points with whoever your educator is - especially when it is not completely C++ and does not work.
Now to echo Salem, what have YOU done to try and solve the problem (trawling the Internet for 'close but not cigars' code does not count) - have YOU written any code yourself?