Method/ function call problem

I'm doing an exercise about method/function calls. Codes below. The exercise asks any code below is wrong. My understanding is the method DisplayProduct calls function Multiply(float a, float b) by supplying two arguments of type float. So what is the purpose of the first statement? Is it simply a wrong statement?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
double Multiply(float, float xyz);

long double DisplayProduct()
{
     double answer = Multiply(1.2F, 2.6F);
     printf("answer = %e", answer);
     return(answer);
}

double Multiply(float a, float b)
{
    return(a * b);
}
Last edited on
The first line is there to tell the computer - make some space for a function in the memory I think. Look at the variable that DisplayProduct should return and what it actually returns.

Compare your function prototype and the actual function heading itself. Can you see an issue?
I see data type mismatches in this exercise but I don't understand the problem. DisplayProduct() should return a long double but it returns a double actually. Long double is large enough to store a double. There should not be any overflow problem. What's the problem?
Same as double Multiply(float a, float b). What's wrong with this data type mismatch?
Thank you
some systems make long double and double same, but you still should be consistent in the code part.
Topic archived. No new replies allowed.