Q:

C Program For Print A Left Pascal Triangle Using Number

belongs to collection: Patterns Basic C Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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:

Enter The No. Of Terms You Want To Print: 6

 1 

 1 1 

 1 2 1 

 1 3 3 1 

 1 4 6 4 1 

 1 5 10 10 5 1 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program For Draw A Perfect Christmas Tree... >>
<< C Programs For Print A Pyramid Pattern Using Star ...