In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. It is named after the French mathematician Blaise Pascal.
Pascal's Triangle |
#include <stdio.h>
long fact(int);
void main()
{
int i, no, c;
printf("Enter Number of Rows : ");
scanf("%d", &no);
for(i = 0; i < no; i++)
{
for(c = 0; c <= (no-i-2); c++)
printf(" ");
for(c = 0; c <= i; c++)
printf("%ld ", fact(i) / ( fact(c) * fact(i-c) ) );
printf("\n");
}
}
long fact(int no)
{
int c;
long result = 1;
for(c = 1; c <= no; c++)
result = result * c;
return result;
}
0 comments :
Post a Comment