Monday, 6 June 2011

Triangle Pattern Program in java

Q.              *
               * * *
             * * * * *
           * * * * * * *

Solution :
             
class triangle
{
public static void main ( String args [ ])
{
for(int row=5 ; row>0 ; row--)
{
for(int space=0 ; space=0 ; space --)
{
System.out.print(" ");
}
for(int col=9 ; col = (row*2)+1 ; col --)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}



No comments:

Post a Comment