Explanation :
If n=6 then output will be
654321
54321
4321
321
21
1.
Code:
import java.util.Scanner;public class Pattern14
{
public static void main( String args[])
{
System.out.print("Enter the number of rows:");
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i = n ; i >= 1 ; i--)
{
for(int j = i; j >= 1 ; j--)
{
System.out.print(j);
}
System.out.println();
}
sc.close();
}
}
No comments:
Post a Comment