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