Java Program to Display Pyramid…

This java code will print a Pyramid.
class Pyr1
{
                public static void main(String args[])
                {
                                int i,j,k;
                                for(i=1;i<=5;i++)
                                {
                                                for(j=1;j<=i;j++)
                                                {
                                                                System.out.print(“*”);
                                                }                             
                                                for(k=2;k<=i;k++)
                                                {
                                                                System.out.print(“#”)    ;
                                                }
                                                System.out.println(“”);
                                }
                }
}

Add Comment