Write a program in C++ that print the following format: For Example: If the input is n=5, the program must print 11 12 21
123 321 1234 4321 123454321
using FOR loop
Answers
Answered by
1
Answer:
1 1
12 21
123 321
1234 4321
1234554321
On first look the pattern may seem little difficult to print out. Lets make things little easier and dissect the given pattern in two internal parts.
1
12
123
1234
123451
21
321
4321
54321
Between these two patterns spaces are printed in decreasing order i.e first row contains 8, second row contains 6 spaces and so on last row contains 0 spaces. Loop formation to print spaces will be for(j=i*2; j<N*2; j++).
Loop to print the above two pattern will be similar and simple. It has also been discussed in one of my earlier post. Lets combine everything in single program.
Similar questions