"Too few arguments in function call" Error?

Hello guys, im having problems with why im getting a "To few arguments in function call" i dont seem to know whats wrong if someone can take a look that would be great!

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162`` `````` #include using namespace std; void calc (int c_num1, int c_den1, char c_op, int c_num2, int c_den2, int &c_num, int &c_den) { switch(c_op){ case '+': c_num = c_num1*c_den2 + c_den1*c_num2; c_den = c_den1*c_den2; break; case '-': c_num = c_num1*c_den2 - c_den1*c_num2; c_den = c_den1*c_den2; break; case '*': c_num = c_num1*c_num2; c_den = c_den1*c_den2; break; case '/': c_num = c_num1*c_den2; c_den = c_den1*c_den2; break;} } int reduce(int r_num1, int r_den1, double &res1, double &res2) { if (r_num1 >= r_den1){ //res = r_num1 / r_den1; //if (res == (int) res) // return true; //else for(int x = r_den1; x >= 2; x--){ res1 = r_num1 / x; res2 = r_den1 / x; if (res1 == (int)res1 && res2 == (int)res2) return true; else x--;}} else{ for(int x = r_num1; x >= 2; x--){ res1 = r_num1 / x; res2 = r_den1 / x; if (res1 == (int)res1 && res2 == (int)res2) return true; else x--;}} } int main() { int n1, d1, n2, d2, num1, den1; char slash1, slash2, oper; cout << "Enter a fraction expression: "; cin >> n1 >> slash1 >> d1 >> oper >> n2 >> slash2 >> d2; calc(n1, d1,oper, n2, d2, num1, den1); reduce(num1, den1); //This is where im getting the error! cout << num1 << "/" << den1; return 0; } ``````
Line 24:
`int reduce(int r_num1, int r_den1, double &res1, double &res2)`
Indicates that reduce() accepts exactly four arguments.
The parameters to which those arguments bind are an `int` named `r_num1`, an `int` named `r_den1`, a lvalue reference to `double` named `res1`, and a lvalue reference to `double` named `res2`.

Line 56:
`reduce(num1, den1); //This is where im getting the error! `
(Tries to) call `reduce()` with only two arguments.

Since res1, res2's referents are modified inside the body of `reduce()`, you should do something like:
 ``5657`` ``````double r1 = 0.0, r2 = 0.0; reduce(num1, num2, r1, r2);``````

Last edited on
Topic archived. No new replies allowed.