package demo;
import java.util.Scanner;
public class BlankPyramid
{
 public static void main(String[] args) 
 {
  Scanner sc = new Scanner(System.in);
  int num;
  System.out.print(“Enter no of rows: “);
  num = sc.nextInt();
  System.out.println(“*”);
  for (int r = 1; r <= num; r++) 
  {
   System.out.print(“*”);
   for (int sp = 1; sp < r; sp++) 
   {
    System.out.print(” “);
   }
   System.out.println(“*”);
  }
  for (int j = 1; j <= num + 2; j++) 
  {
   System.out.print(“*”);
  }
 }
}


Output:
Enter no of rows: 4


*
**
* *
*  *
*   *

******


BUILD SUCCESSFUL (total time: 3 seconds)

LEAVE A REPLY

Please enter your comment!
Please enter your name here