Pascal Triangle

Pascal Triangle

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Pascal Triangle
Pascal Triangle

Write a C program to Pascal Triangle

PROGRAM: Pascal Triangle

1
1 1
1 2 1
1 3 3 1 
1 4 6 4 1

long fact(int);

int main()
{
   int i, j;
   for (i=0;i<5;i++)
   {
      for(j=0;j<=i;j++)
      {
         printf("%ld ",fact(i)/(fact(j)*fact(i-j)));
      }
      printf("\n");
   }
   return 0;
}
 
long fact(int n)
{
    int i;
    long f = 1;
    for(i=1;i<=n;i++)
      f = f*i;
    return f;
}

Leave a Reply

Your email address will not be published. Required fields are marked *