5/17/2016

C Program For Print A Left Pascal Triangle Using Number

Pascal's triangle :- In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In much of the Western world it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Iran, China, Germany, and Italy.
C Program For Print A Left Pascal Triangle Using Number


Solution :-

#include<stdio.h>

long fact(int);

int main()
{
    int counter,i,j;

    printf("Enter The No. Of Terms You Want To Print: ");
    scanf("%d",&counter);

    for(i=0;i<counter;i++)
 {    
  printf(" ");
         for(j=0;j<=i;j++)
             printf("%ld ",fact(i)/(fact(j)*fact(i-j)));
         printf("\n");
    }
    
    return 0;
}
//function starting 
long fact(int num)
{
    long f=1;
    int i=1;
    while(i<=num)
 {
         f=f*i;
         i++;
  }
  return f;
  //funtion returning a value 
 }

Output:-

C Program For Print A Left Pascal Triangle Using Number

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: