Welcome to ICSE Java Answers. Ask any questions you have related to Java and we will answer them.
Java is a registered trademark of Oracle. This site is in no way related to or endorsed by Oracle.

Print the following pattern

0 votes
1
      21
    321
  4321
54321
asked by Ash

1 Answer

0 votes
import java.util.*;
 class PatternExample{
    public static void main(String[] args){
        int a,i,j,k;
        Scanner input= new Scanner(System.in);
        System.out.println("Enter a Number:");
        a=input.nextInt();
        for (i = 1; i <= a; i++) {
            for(k=a;k>=i;k--){
                System.out.print(" ");
            }
            for (j = i; j > 0; j--) {
                System.out.print("" + j);
            }
            System.out.println("");
        }
    }
}
answered by Programmer (25 points)
edited by Programmer
...