Java Program To Pascal Triangles Without using any string functions/packages
import java.io.*;public class PascalTriangle{
public static void main(String args[])
{
try
{
System.out.print(" Enter no of rows : ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int row=Integer.parseInt(br.readLine());
int b=1,q=0;
while(q0;p--)
System.out.print(" ");
for(int x=0;x<=q;x++)
{
if(x==0||q==0)
b=1;
else
b=(b*(q-x+1)/x);
System.out.print(b+" ");
}
System.out.print("\n\n");
q++;
}
}catch(Exception e){}
}
}
Loading...
|
Comments :
Post a Comment