Java Program to print the following pattern

Java Program to print the following pattern:

        1
      21
    321
  4321
54321


public class aa
{
public static void main(String args[])
{
int a,b,c=0;
for (a=1;a<=5;a++)
{
for (b=5;b>=a;b--)
{
System.out.print(" ");
}
for(c=a;c>=1;c--)
{
System.out.print(c);
}
System.out.println();
}
}
}

Output:

Post a Comment

Previous Post Next Post