Gubbas Digi Communications

Gubbas Digi Communications

Star Pyramid




Star pyramid




class Pyramid

{
public static void main(String[] args)
{
int row=0,c=0;
int n=5,temp;
temp=n;
        for(row=0;row<6 ;row++ )
{
for(c=0;c<n;c++)
        {
System.out.print(" ");
        }
n--;
for(int i=n;i<temp;i++)
{
System.out.print("*");
}
temp=temp+1;
System.out.println();
}
}
}
Output:

                   *
                                   ***
                                 *****
                               *******
                             *********


No comments:

Post a Comment