calculate values code corrections

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jchimanzi
    New Member
    • Feb 2007
    • 20

    calculate values code corrections

    How can i rewrite the following code correcting all problems found

    void calculatevalues (const int &a, float *b, int &c)

    {
    d = 20.4;

    if (*a =0)

    *a += 1
    c = a +d;

    else

    b= c/d ;

    c= a- b +d;

    }

    Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by jchimanzi
    How can i rewrite the following code correcting all problems found

    void calculatevalues (const int &a, float *b, int &c)

    {
    d = 20.4;

    if (*a =0)

    *a += 1
    c = a +d;

    else

    b= c/d ;

    c= a- b +d;

    }

    Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15
    What have you tried on this? Can you post your answer? What error messages have you gotten? (People are more likely to help if they see that you have actually tried, instead of you just copying and pasting your homework to try to get us to do it.)

    Comment

    Working...