Prove that sum of kth and k-1th number in the n-1th row of Pascal’s triangle is equal to kth number in nth row of the triangle. code example

Example: how to find the nth row of pascal's triangle in c

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N;

  scanf("%d", &N);
  int pascalArray[N + 1][N + 1];
  int i, j;
  if(0 <= N && N <= 20)
  {
      for (i = 0; i < N + 1; i++)
      {
        for(j = 0; j <= i; j++)
        {
            if(j == 0 || j == i)
                pascalArray[i][j] = 1;
            else
                pascalArray[i][j] = pascalArray[i-1][j-1] + pascalArray[i-1][j];
            if (i == N)
                printf("%d ", pascalArray[i][j]);
        }
      }
  }
  return 0;
}

Tags:

C Example