Thursday 20 July 2017

To print traingle with stars

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


OUTPUT:
     *
   ***
  *****
 *******

*********

No comments:

Post a Comment