"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!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  #include <iostream>
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:
56
57
double r1 = 0.0, r2 = 0.0; 
reduce(num1, num2, r1, r2);

Last edited on
Topic archived. No new replies allowed.