Question: #include #include int facto(int); main(void) { int n,r,nr,factN,factR,factNR; double p,result; printf(binomial distribution ); printf(enter the value of n:); scanf(%d,&n); printf(enter the value of r:); scanf(%d,&r);

#include

#include

int facto(int);

main(void)

{

int n,r,nr,factN,factR,factNR;

double p,result;

printf("binomial distribution ");

printf("enter the value of n:");

scanf("%d",&n);

printf("enter the value of r:");

scanf("%d",&r);

printf("enter the value of p:");

scanf("%lf",&p);

nr=n-r;

factN=facto(n);

factR=facto(r);

factNR=facto(nr);

result=(((factN/factR)*factNR)*pow(p,r)*(pow((1-p),nr)));

printf(" result=%.3lf",result);

getch();

}

int facto(int n)

{

return (n==1 || n==0) ? 1 : facto(n-1)*n;

}

Please re-write the following code for binomial distribution but using functions and arrays. Thanks! (C program)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!