Question 30 : Write a program in Java to print the following pattern :
*
* *
* *
* *
* *
********
Java Program :
public class pattern_18
{
public static void main()
{
int i,j,k;
System.out.println(" * ");
for(i=1;i<=7;i=i+2)
{
for(j=8;j>=i;j=j-2)
{
System.out.print(" ");
}
System.out.print("*");
for(k=1;k<=i;k++)
{
System.out.print(" ");
}
System.out.print("*");
System.out.print("\n");
}
System.out.println("***********");
}
}
No comments:
Post a Comment