Write a Program in
java to print the following pattern
*
***
*****
*******
*********
*******
*****
***
*
Program:
class Sk23
{
public
static void main(String args[ ])
{
int i, j,
k;
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.println("");
}
for(i=4;i>=1;i--)
{
for(j=5;j>i;j--)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
Compile:
D:\>javac
Sk23.java
Run:
D:\>java Sk23
Output:
*
***
*****
*******
*********
*******
*****
***
*
0 Comments