class
displaydemo
{
public
static void main(String args[])
{
int
n=1;
int
ln=1,l;
char
ch='*';
while(ln<=5)
{
for(l=1;l<=ln;l++)
{
System.out.print(ch+"
");
}
System.out.println();
ln++;
}
while(ln>0)
{
for(l=1;l<=ln;l++)
{
System.out.print(ch+"
");
}
System.out.println();
ln--;
}
}
}
Output:
To compile this code use below command
D:\JavaPrograms\SimplePrograms>javac displaydemo.java
To run this code use below command
D:\JavaPrograms\SimplePrograms> java displaydemo
*
*
*
*
* *
*
* * *
*
* * * *
*
* * * * *
*
* * * *
*
* * *
*
* *
*
*
*
0 Comments
Post a Comment