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

Q. *
*
*
*
*
Solution :
class pattern
{
public static void main ( String args [ ] )
{
for( int row=5; row>0 ; row--)
{
for( int col=0; col < row ; col++)
{
System.out.print(" ");
}
System.out.println("*");
}
}
}
* * *
* * * * *
* * *
*
Solution :
class pattern
{
public static void main (String args[ ])
{
for(int row=5 ; row>0 ; row--)
{
for(int space=0 ; space<r ; space--)
{
System.out.print(" ");
}
for(int col=9 ; col>=(row*2)+1 ; col--)
{
System.out.print("*");
}
System.out.println( " ");
}
for(int row=2 ; row>0 ; row--)
{
for(int space=0 ; space<row ; space++)
{
System.out.print( " ");
}
for(int col=9 ; col>=(row*2)+1 ; col--)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
Q. *
*
*
*
*
Solution :
class pattern
{
public static void main ( String args [ ] )
{
for( int row=5; row>0 ; row--)
{
for( int col=0; col < row ; col++)
{
System.out.print(" ");
}
System.out.println("*");
}
}
}
No comments:
Post a Comment