Computer Science, asked by amansoni88, 4 months ago

write the program series
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
5 4 3 2 1 0
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5​

Answers

Answered by anindyaadhikari13
5

Answer:

The program for the above pattern is given below. See the attachment for output.

1. In Java.

public class Java {

public static void main(String[] args) {

int i, j;

for(i=5;i>=0;i--) {

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

System.out.print(j+" ");

System.out.println();

}

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

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

System.out.print(j+" ");

System.out.println();

}

}

}

2. In Python.

for i in range(5,-1,-1):

for j in range(5,i-1,-1):

print(j,end=" ")

print()

for i in range(1,6):

for j in range(5,i-1,-1):

print(j,end=" ")

print()

3. In C.

#include <stdio.h>

void main() {

int i, j;

for(i=5;i>=0;i--) {

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

printf("%d ", j);

printf("\n");

}

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

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

printf("%d ", j);

printf("\n");

}

}

4. In C++.

#include <iostream>

using namespace std;

int main() {

int i, j;

for(i=5;i>=0;i--) {

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

cout << j << " ";

cout << endl;

}

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

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

cout << j << " ";

cout << endl;

}

return 0;

}

Attachments:
Similar questions