+2 votes
in Class 10 by kratos

WAP to generate the following pascal’* triangle.

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 Answer

+2 votes
by kratos
 
Best answer

import java.io.*;

class pascal

{

public static void main ( ) throws IO Exception

{

InputStreamReader read = new InputStreamReader ( System.in));

BufferedReader in = new BufferedReader (read);

int i, j, n;

int m [ ] =new int [20];

System.out.printIn (“Enter the size of the pascal triangle”);

n=Integer.parseIn(in.readLine ( ));

m [0] =1;

for (i=0; k<n; i++)

{

for (j=0; j<=i; j++)

{

for (j=0; j<=i; j++)

System.out.print(m[j]+” “);

System.out.printIn ( );

for (j=i+1; j>0; j--)

m[j] = m[j] + m[j – 1];

}

}

}

...