public class p10
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5;j++)
{
if(i<=j)
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
}
OUTPUT
* * * * *
* * * *
* * *
* *
*
public class P30
{
public static void main(String[] args)
{
for(int i=5; i>0; i--)
{
for(int j=1; j<=5;j++)
{
if(i>=j)
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
}
OUTPUT
* * * * *
* * * *
* * *
* *
*
public class P28
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5;j++)
{
if(i>=j)
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
}
OUTPUT
*
* *
* * *
* * * *
* * * * *
public class P29
{
public static void main(String[] args)
{
for(int i=5; i>0; i--)
{
for(int j=1; j<=5;j++)
{
if(i<=j)
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
}
OUTPUT
*
* *
* * *
* * * *
* * * * *
No comments:
Post a Comment
If you have any doubts, please let me know