11111
2222
333
44
5
Java pattern programme
Answers
Answered by
7
Program :
import java.util.*;
import java.lang.*;
import java.io.*;
class Prog
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner Sc = new Scanner(System.in);
int n;
System.out.print("Enter the height of the pattern : ");
n = Sc.nextInt();
for(int i = 1 ; i <= n ; i++)
{
for(int j = n ; j >= i ; j--)
{
System.out.print(i + " ");
}
System.out.println();
}
}
}
Output :
Enter the height of the pattern : 5
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
Similar questions