0% found this document useful (0 votes)
21 views1 page

P 3

The document contains C code to print Pascal's triangle. It includes functions to calculate factorials and combinations needed to generate each row and prints the triangle up to a given number of rows input by the user.

Uploaded by

Kalyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

P 3

The document contains C code to print Pascal's triangle. It includes functions to calculate factorials and combinations needed to generate each row and prints the triangle up to a given number of rows input by the user.

Uploaded by

Kalyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.

h>
int fact(int m)
{
int k=1;
for(int i=1;i<=m;i++)
{
k=k*i;
}
return k;
}
int comb(int a,int b)
{
return(fact(a)/(fact(b)*fact(a-b)));
}
void pasc(int n)
{
for(int i=1;i<=n-1;i++)
{

if(i==1)
{
printf("%d",1);
printf("\n");
}
for(int j=0;j<=i;j++)
{

printf("%i",comb(i,j));
printf(" ");
}
printf("\n");
}
}
int main()
{
int num;
scanf("%d",&num);
printf("\n");
pasc(num);
return 0;
}

You might also like