Computer Science, asked by suprith10dchs, 6 months ago

5
4 4
3 3 3
2 2 2 2
1 1 1 1 1

print the java program​

Answers

Answered by shaswatpathak9508
2

Answer:

//printing format

class no_frm

{

void display no_frm()

{

int rctr=0,cctr=0;

for(rctr=5;rctr>=1;rctr--)

{

for(cctr=1;cctr<=5;cctr++)

{

System.out.print(rctr);

}

System.out.println();

}}}

Answered by anindyaadhikari13
1

Question:-

Write a program in Java to print the following pattern.

5

44

333

2222

1 1 1 1 1

Program:-

Here is your program written in Java.

import java.util.*;

class Pattern

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number of rows for the pattern: ");

int n=sc.nextInt();

for(int i=n;i>=1;i--)

{

for(int j=i;j<=n;j++)

{

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

}

System.out.println();

}

}

}

Take the input from the user and you will get the desired output.

Similar questions