Error problem

I have a problem to do for class. We are to create a function named mult() that accepts two floating-point numbers as parameters, multiplies the two numbers, and outputs them. I wrote the program however I keep getting an error code,telling me the function does not take 0 arguments. Please help me.

#include <iostream>
using namespace std;

float mult(float x, float y)
{
cin >> x;
cin >> y;
cout << x*y << endl;
return 0;
}

int main()
{
cout << mult() << endl;

return 0;
}

I am getting the error at line 14 which is the line that reads " cout << mult() << endl;

thanks in advance.
That is because you said by definition of mult (see parameter list), you need 2 arguments, x and y in this case.

I mean, it is like i would tell to you: "Hey you, multiply!" You would respond: "What should i multiply? you did not give me any numbers!". The compiler just does the same now. The function multiply do not take 0 (or no) arguments. Give him some numbers and he will multiply. Something like
 
mult(3,13)

will do it
Thank you very much I appreciate it.
You're not supposed to have cin in your mult function.

The idea is to multiply the numbers passed to the function

You're throwing away the numbers passed to the function, and replacing them with numbers you get from the user (via cin).
Last edited on
Topic archived. No new replies allowed.