Java Program to print the star pattern, Program in java to make Triangle of star in java
*
**
***
****
*****
****
***
**
*
Program
class star
{
public static void main(String args[])
{
int n=Integer.parseInt(args[0]);
int i;
for(i=0;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
for(i=n-1;i>=0;i--)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
Click here to check the output
*
**
***
****
*****
****
***
**
*
Program
class star
{
public static void main(String args[])
{
int n=Integer.parseInt(args[0]);
int i;
for(i=0;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
for(i=n-1;i>=0;i--)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
Click here to check the output
No comments:
Post a Comment