Jul 9, 2007

JAVA Program :

// Java Program To Generate Follwing Pyramid

//543212345
//5432 2345
//543 345
//54 45
//5 5

class series
{
public static void main(String[] args)
{

int a=1,z=0;
for (int k=1;k<=5 ;k++ )
{

for (int i=5;i>=a;i-- )
{
System.out.print(i+"");
}

for (int j=1;j<=z;j++ ) // loop to print blanks
{
System.out.print(" ");
}

for (int i=a;i<=5;i++ )
{
System.out.print(i+"");
}
System.out.println();
a=a+1;
z=z+1;
}
}
}

No comments:

Post a Comment