A simple java program on pyramid pattern.
To make the program simple we did not use any Scanner class for input.
For loop is being used mainly.
for(i=1;i<=n;i++)
{
for(j=1;j<=l;j++)
{
System.out.print(" ");
}
for(k=1;k<=2*i-1;k++)
{
System.out.print("*");
}
l--;
}
in the last for loop we have used the formula
for(k=1;k<=2*i-1;k++)
since we need a pyramid pattern of
*
***
*****
*******
*********
which is of the order 2*i-1.