Need help fixing these errors

I'm writing a program that takes input in the form of two fractions and then performs multiplication division subtraction or addition. I must use the 4 functions specified in my code. I'm getting an error about an unresolved external symbol in the 3rd function. I also want to test to see if the user entered a multiplication symbol in the if statement so I can perform multiplication.
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
  #include <iostream>
#include <string>

using namespace std;

void programInformation();
void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand);
void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree, char slash, char operand);
void displayResult(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree);

int main()
{
	int  nOne;
	int  nTwo;
	int  dOne;
	int  dTwo;
	int  nThree;
	int  dThree;
	char slash;
	char operand;

	programInformation();
	inputData(nOne, dOne, nTwo, dTwo, slash, operand);
	calculationFraction(nOne, dOne, nTwo, dTwo, nThree, dThree, slash, operand);
	return 0;
}

void programInformation()
{
	cout << "Welcome to my Fraction Calculation Program!" << endl;
	cout << "Please follow instructions carefully." << endl;

}

void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree, char slash, char operand)
{

	cout << "Enter your operation like 1/2 + 1/4." << endl;
	cin >> nOne >> slash >> dOne >> operand >> nTwo >> slash >> dTwo;
	cout << "Enter your expect result." << endl;
	cin >> nThree >> slash >> dThree;
}

void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, int&nThree, int&dThree, char slash, char operand)
{
	if (operand == *)
	{
		n1 * d2 + n2 * d1 = n3
                n2 * d2 = d3
	}
	else
	{
		cout << "failed.";
	}
}
Last edited on
On line 24 you use variables that have no value as input... (nThree, dThree)
thanks, that fixed a majority of the errors. But now i'm getting a run time error saying that slash and operand are being used without being initialized. Here's the few changes I made.

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
#include <iostream>
#include <string>

using namespace std;

void programInformation();
void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand);
void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand);
void displayResult(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree);

int main()
{
	int  nOne;
	int  nTwo;
	int  dOne;
	int  dTwo;
	char slash;
	char operand;
	programInformation();
	inputData(nOne, dOne, nTwo, dTwo, slash, operand);
	calculationFraction(nOne, dOne, nTwo, dTwo, slash, operand);
	return 0;
}

void programInformation()
{
	cout << "Welcome to my Fraction Calculation Program!" << endl;
	cout << "Please follow instructions carefully." << endl;

}

void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand)
{
	
	int nThree;
	int dThree;
	cout << "Enter your operation like 1/2 + 1/4." << endl;
	cin >> nOne >> slash >> dOne >> operand >> nTwo >> slash >> dTwo;
	cout << "Enter your expect result." << endl;
	cin >> nThree >> slash >> dThree;
}

void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand)
{
	if (operand == 3)
	{
		cout << "test.";
	}
	else
	{
		cout << "boo.";
	}
}
In inputdata() slash and operand is not a reference parameter, so when both of it coming back to main it still has no value
ok i referenced those variables in the argument and the program is working for now. thanks!
Topic archived. No new replies allowed.