In: Computer Science
The probability that a telephony call will last t minutes can be approximated as -
Probability that call lasts less than t minutes =1 - e-t/a
Where e = Euler’s constant (2.71828) and a = average call duration
Using the above probability function, write a program in C that
a. takes the average call duration (a) from the user,
b. then accepts the call duration to find the probability for (t) and
c. then calculates and prints the probability that a call lasts less than t.
The program should repeat the sequence of operations a to c until the user enters a value of 0 for either variable a or t in the steps a or b above
#include<stdio.h>
#include<math.h>
int main(){
double a=1,t=1,p;
while(a!=0&&t!=0){
printf("Enter average call duration
(a): ");
scanf("%lf",&a);
if(a!=0){
printf("Enter call duration to find
the probability for (t): ");
scanf("%lf",&t);
if(t!=0){
p=1-exp(-t/a);
printf("The
probability that a telephony call will last %.2f minutes:
%f\n\n",t,p);
}
}
}
return 0;
}