Java program for Star pyramid


Java program for Star pyramid 


import java.util.Scanner;
public class Pyramid{
public static void main(String args[ ])
{
   Scanner s=new Scanner(System.in);
int i , j, n; 
System.out.println("Enter the number of lines");
n=s.nextInt();
for(i=1;i<=n;i++)
{
  for(j=1;j<=i;j++)
  { 
   System.out.print("*");
  }
System.out.println(" ");
}
}
}

Output 

Enter the number of lines
5
*
**
***
****
*****

Comments