0% found this document useful (0 votes)
21 views2 pages

3 D PascalsTriangle

The document contains a C program to print Pascal's triangle. It takes the number of rows as input from the user, declares arrays to store the values, uses nested for loops to calculate the binomial coefficients and print the triangle. The program outputs the Pascal's triangle of the given number of rows.

Uploaded by

Alagar Raja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

3 D PascalsTriangle

The document contains a C program to print Pascal's triangle. It takes the number of rows as input from the user, declares arrays to store the values, uses nested for loops to calculate the binomial coefficients and print the triangle. The program outputs the Pascal's triangle of the given number of rows.

Uploaded by

Alagar Raja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name : B.

Kevin
Roll no: 54
PROGRAM :
#include<stdio.h>
#include<conio.h>
main()
{
int a[15][15], i, j , rows , num = 25 , k;

/*variable declaration*/

printf("\n Enter the number of rows:");


scanf("%d", &rows);
rows*/

/*getting the number of

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


{
for(k= num-(2*i) ; k>=0 ; k--)
printf(" ");
for(j=0;j<=i;j++)
{
if(j==0||i==j)
{
a[i][j]=1;
}
else
{

/*loop to generate the triangle*/

a[i][j]=a[i-1][j-1]+a[i-1][j];
}
printf("%4d",a[i][j]);
}
printf("\n");
}
getch();
}

Output:
Enter the number of rows: 6

/*printing the triangle*/

You might also like