import java.io.*;
class printPyramidDemo
{
public static void main(String arg[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the height of pyramid ");
String s=br.readLine();
int a=Integer.parseInt(s);
for(int i=0; i<=a; i++)
{
for(int k=a; k>=i; k--)
{
System.out.print(" ");
}
int c=(2*i)-1;
for(int j=1; j<=c; j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
class printPyramidDemo
{
public static void main(String arg[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the height of pyramid ");
String s=br.readLine();
int a=Integer.parseInt(s);
for(int i=0; i<=a; i++)
{
for(int k=a; k>=i; k--)
{
System.out.print(" ");
}
int c=(2*i)-1;
for(int j=1; j<=c; j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
output
No comments:
Post a Comment