0

What is the loop of the pattern

1 12 123 1234

8th May 2017, 5:30 PM
dinesh gupta
dinesh gupta - avatar
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
8th May 2017, 5:42 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
for(int i=1;i<5;i++) { for(int j=1;j<=i;j++) { cout<<j; } cout<<endl; }
8th May 2017, 6:11 PM
P Sandesh Baliga
P Sandesh Baliga - avatar
+ 1
You could also use recursion
8th May 2017, 10:05 PM
Mrs. Coder123
Mrs. Coder123 - avatar