Tuesday 22 January 2013

binomial co efficiecnt


#include<stdio.h>
#include<conio.h>
 int binomial(int n,int k)
{
int i,j,a[10][10];
for(i=0;i<=n;i++)
{
a[i][0]=1;
a[i][i]=1;
}
for(i=2;i<=n;i++)
{
for(j=1;j<=i-1;j++)
{
a[i][j] = a[i-1][j] + a[i-1][j-1];
}
}
return a[n][k];
}
int main()
{
int n,k,res;
printf("\n Enter the value for n : ");
scanf("%d",&n);
printf("\n Enter the value for k : ");
scanf("%d",&k);
res=binomial(n,k);
printf("\n The binomial co-efficient is %d\n",res);
getch();
}

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2022