Pattern: Inverse Pyramid
Output:
6
* * * * * *
* * * * *
* * * *
* * *
* *
*
Aim: TO Print An Inverse Pyramid of Stars Using JAVA. Get the User Input of No. of Stars and Print Following pattern.
Output:
6
* * * * * *
* * * * *
* * * *
* * *
* *
*
Syntax:
import java.util.*;
class pyramid_inverse
{
public static void main(String args[])
{
int n;
Scanner scanner=new Scanner(System.in);
System.out.println("Enter A Number");
n=scanner.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=1;j<i;j++)
{
System.out.print(" ");
}
for(int k=n;k>=i;k--)
{
System.out.print(" *");
}
System.out.println();
}
}
}
Comments
Post a Comment