Skip to content
Home » Pascal Triangle Program in C Without Using Array

Pascal Triangle Program in C Without Using Array

Learn about Pascal Triangle Program in C Without Using Array in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Pascal Triangle Program in C Without Using Array

Source code:

#include<stdio.h>
int main()
{
  int n;
  printf("Enter the number of rows: ");
  scanf("%d",&n);
  for(int row=1; row<=n; row++)
  {
    int a=1;
    for(int i=1; i<=row; i++)
    {
      printf("%d ",a);
      a = a * (row-i)/i;
    }
    printf("\n");
  }
  return 0;
}

Output:

Enter the number of rows: 6
1 
1 1 
1 2 1 
1 3 3 1 
1 4 6 4 1 
1 5 10 10 5 1 

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Reverse Floyd’s triangle in C
Floyd’s triangle in C using recursion