Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
971 views
in Computer by (73.1k points)

WAP to generate the following pascal’s triangle.

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1 

1 Answer

+1 vote
by (69.1k points)
selected by
 
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];

}

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...