Wednesday, 27 July 2011

simple program for printing the following pyramid using for loop



                                                            1                  2                 1
                                       1                  2                 3                 2                 1
       1                  2                 3                 4                 3                 2                 1
1                 2                 3                 4                 5                 4                 3                 2                 1




class a

{

Public static void main(String args[])

{

int I,j,k,l;
for(i=1; i<=5;i++)

{

for(i=5;1>=I;1--)

System.out.printl(“\t”)

for(j=1;j<=I;j++)

System.out.println(J+”\t”);

for(k=i-1;k=1;k--)

System.out.print(k+”\t”);

System.out.println( );

}

}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More