Write a c program to calculate probability using binomial distribution and poisson distribution
Answers
Answer:
Step-by-step explanation:
Program
#include<stdio.h>
#include<math.h>
#include<conio.h>
int facto(int);
void main()
{
double p,result;
int n,r,nr,factN,factR,factNR;
printf("binomial distribution\n");
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("\n result=%.3lf",result);
getch();
}
int facto(int num)
{
return (num==1 || num==0) ? 1 : facto(num-1)*num;
}