Contact Learn C
Copy Program Share Program

Program 79:Pascals Triangle

Program 79: What is Pascal's Triangle?
#include<stdio.h>
#include<math.h>
main()
{
    int i,j,k,rows,count;
    long x;
    printf("Enter number of rows\n");
    scanf("%d",&rows);
    count=rows-1;
    for(i=0;i<rows;i++)
    {
        x=1;
        for(k=0;k<=count;k++)
        {
            printf("   ");
        }
          for(j=0;j<=i;j++)
        {
            printf("%6ld",x);
            x=(x*(i-j)/(j+1));
        }
        count--;
        printf("\n");
    }
}
Explanation:

//Coming Soon...

 Output:

Pascals Triangle
 

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide