Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

thangeram Group Title

#include<stdio.h> #include<conio.h> #include<math.h> float fact(int x); void main() { int n,x,m,a; float pmf,mean,var,p,q,ncr; printf("\t\t**********poisson Distribution***************\n"); scanf("%d",&x); printf("\nEnter value for alpha: "); scanf("%d",&a); pmf=(exp(-a)*pow(a,x))/fact(x); mean=a; var=a; printf("\n\nMean: %f\nVariancd: %f\npmf:%f",mean,var,pmf); getch(); } float fact(int f) { int i; float s=1.0; for(i=f;i>0;i--) { s=s*1; } return s; } help me friends its urgent i cant find satisfying output

  • one year ago
  • one year ago

  • This Question is Closed
  1. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    hi thangeram, what's the purpose of fact function ?

    • one year ago
  2. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    to check condition that ans must be below 1 and to calulate pmf

    • one year ago
  3. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    as I can see that function (fact) always returns a value of 1.0

    • one year ago
  4. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    hmm your correct but nick tell me why it is not giving satisfying output

    • one year ago
  5. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I don't know what the "fact" function should do on its input f

    • one year ago
  6. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i am showing you another example

    • one year ago
  7. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #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; }

    • one year ago
  8. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    may be it should evaluate the factorial value of f ? (f * f-1 * f-2 *...*1)

    • one year ago
  9. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    in that case you should have: float fact(int f) { float s=1.0; while(f>0) { s=s*f; f--; } return s; }

    • one year ago
  10. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thanx nick

    • one year ago
  11. nick67 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    you're welcome :-)

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.