C Program to print Pascal Triangle

What is Pascal Triangle?

The Pascal triangle is a triangular array of binomial coefficients. It looks like this:

The following is a formula to compute the value at any given place in the triangle:

\begin{pmatrix}n\\k\end{pmatrix} = \frac{n!}{k!(n-k)!}

where n stands for the row number and k stands for the column number. Note that the rows start from 0 and also the leftmost column is 0. So, to find out the value at 4th row, 2nd col, we do this:

\begin{pmatrix}4\\2\end{pmatrix} = \frac{4!}{2!(4-2)!} = \frac{4!}{2!2!} = \frac{4*3}{2*1}  = 6

The following is a C program which prints the pascal triangle based upon the number of rows entered by the user:

Expected Output:


Recommended Reading:

Leave a Comment

%d bloggers like this: