Tuesday, 17 May 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

No comments:
Write comments

Recommended Posts × +