Sathvikks8

a C Program to generate binomial coefficient for B(n,r) usin

May 14th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<stdio.h>
  2. int bi_coeff(int a);
  3. void main()
  4. {
  5.     int n;
  6.     printf("Enter the number of rows: ");
  7.     scanf("%d",&n);
  8.     bi_coeff(n);
  9. }
  10. int bi_coeff(int a)
  11. {
  12.     int i,j,result=1;
  13.     for(i=0;i<a;i++)
  14.     {
  15.         for(j=0;j<=i;j++)
  16.         {
  17.             if(i==0||j==0)
  18.                 result=1;
  19.             else
  20.                 result=(result*(i-j+1))/j;
  21.             printf("%d ",result);
  22.         }
  23.         printf("\n");
  24.     }
  25.            
  26. }
Add Comment
Please, Sign In to add comment