#include <stdio.h>// See https://www.geeksforgeeks.org/archives/25621// for details of this functionint binomialCoeff(int n, int k);
// Function to print first// n lines of Pascal's// Trianglevoid printPascal(int n)
{
// Iterate through every line and// print entries in itfor (int line = 0; line < n; line++)
{
// Every line has number of// integers equal to line// numberfor (int i = 0; i <= line; i++)
printf("%d ",
binomialCoeff(line, i));
printf("\n");
}
}
// See https://www.geeksforgeeks.org/archives/25621// for details of this functionint binomialCoeff(int n, int k)
{
int res = 1;
if (k > n - k)
k = n - k;
for (int i = 0; i < k; ++i)
{
res *= (n - i);
res /= (i + 1);
}
return res;
}
// Driver programint main()
{
int n = 7;
printPascal(n);
return0;
}

Patrica Millie