public class Print{
public static void main(String[] args)
{
int i=1;
int j;
while(i<=7)
{
for(j=1;j<=i;j++)
System.out.print("*");
i=i+2;
System.out.println();
}
i=5;
while(i>=1)
{
for(j=1;j<=i;j++)
System.out.println();
}
}
}
output:
C:\>javac Print.java
C:\>java Print
*
***
*****
*******
*****
***
*
public static void main(String[] args)
{
int i=1;
int j;
while(i<=7)
{
for(j=1;j<=i;j++)
System.out.print("*");
i=i+2;
System.out.println();
}
i=5;
while(i>=1)
{
for(j=1;j<=i;j++)
System.out.println();
}
}
}
output:
C:\>javac Print.java
C:\>java Print
*
***
*****
*******
*****
***
*
No comments:
Post a Comment