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 discussion on finding difficulties within the C++ Programming forums, part of the General Programming Boards category; how do we write a for loop which will produce the following output using two nested for loops 1 22 ...
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?
need help
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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"); }
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 dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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?
Any help I give may be classified as:Currently working through:
The Blind leading the Blind...
"C++ Primer Plus"