Computer Science, asked by pundiraryan57, 4 months ago

write a C program to print :
1
212
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5​

Answers

Answered by anindyaadhikari13
0

Answer:

This is the required program for the question.

This program is written in C.

#include <stdio.h>

int main () {

int i,j;

for(i=1;i<=5;i++) {

for(j=i;j>=1;j--)

printf("%d ",j);

for(j=2;j<=i;j++)

printf("%d ", j);

printf("\n");

}

return 0;

}

The pattern is divided into two parts,

1

21

3 2 1

4 3 2 1

5 4 3 2 1

And,

2

2 3

2 3 4

2 3 4 5

Outer loop determines the number of rows. Here, the number of rows is 5.

First inner loop prints the first part of the pattern and the second inner loop prints the second part of the pattern.

A new line is printed after displaying the row.

See the attachment for output .

Attachments:
Similar questions