#include
hi thangeram, what's the purpose of fact function ?
to check condition that ans must be below 1 and to calulate pmf
as I can see that function (fact) always returns a value of 1.0
hmm your correct but nick tell me why it is not giving satisfying output
I don't know what the "fact" function should do on its input f
i am showing you another example
#include <stdio.h> #include <math.h> /* protype of "e", exp(x) == exp^x */ #include <conio.h> /* For clrscr() */ double Factorial1 (double a) { double answer = 1.0; while(a>1) answer *= a--; return answer; } int main(void) { double result, res1, res2; double i = 0.0, k = 0.00; double answer = 0.0; result = res1 = res2 = 0.0; /* makes it easier to see input prompts */ printf("Enter mean: "); scanf("%lf", &i); printf("Enter value of interest: "); scanf("%lf", &k); /* factorial of value of interest */ answer = Factorial1(k); /* formula for k */ result = pow(i,k); res1 = 1/(exp(k)); res2 = (result * res1) / answer; printf("answer is ... : %0.20lf", res2); return 0; }
may be it should evaluate the factorial value of f ? (f * f-1 * f-2 *...*1)
in that case you should have: float fact(int f) { float s=1.0; while(f>0) { s=s*f; f--; } return s; }
thanx nick
you're welcome :-)
Join our real-time social learning platform and learn together with your friends!