0
What is the loop of the pattern
1 12 123 1234
3 Answers
+ 13
Hints:
- Use nested loop! (Lines should be printed in outer loop, and numbers should be printed in inner loop)
- 4 lines should be printed
- Each line should be started from 1 and print upto that line number. (For example, 3rd line should print 1 to 3)
- After printing the numbers in each line, you must print a new line
+ 2
for(int i=1;i<5;i++)
{
for(int j=1;j<=i;j++)
{
cout<<j;
}
cout<<endl;
}
+ 1
You could also use recursion