Menu



Java Program for displaying Pascal Star


Pascal.java

import java.util.Scanner;
class Pascal
{
public static void main(String[] args)
{
int pascal,a,b,c,x;
Scanner s=new Scanner(System.in);
System.out.println("How Many Row Do you want to input: ");
c=s.nextInt();
pascal=1;
b=0;
System.out.print("Pascal's Triangle: ");
while(b {
for(a=40-3*b;a>0;--a)
System.out.print(" ");
for(x=0;x<=b;++x)
{
if((x==0)||(b==0))
pascal=1;
else
pascal=(pascal*(b-x+1))/x;
System.out.print(" ");
System.out.print(pascal);
}
System.out.println("");
++b;
}
}
}
pascal star