Getting Error in C++ code need help

1030071002
1030071002 used Ask the Experts™
on
Getting Error need a solution

Error      1      error C2664: 'addfraction' : cannot convert parameter 5 from 'int *' to 'int &'      c:\Users\remote desktop\Documents\Visual Studio 2005\Projects\Calculator\Calculator\Calculator.cpp      79      
Error      2      error C2664: 'subtractfraction' : cannot convert parameter 5 from 'int *' to 'int &'      c:\Users\remote desktop\Documents\Visual Studio 2005\Projects\Calculator\Calculator\Calculator.cpp      82      
Error      3      error C2664: 'multiplyfraction' : cannot convert parameter 5 from 'int *' to 'int &'      c:\Users\remote desktop\Documents\Visual Studio 2005\Projects\Calculator\Calculator\Calculator.cpp      85      
Error      4      error C2664: 'dividefraction' : cannot convert parameter 5 from 'int *' to 'int &'      c:\Users\remote desktop\Documents\Visual Studio 2005\Projects\Calculator\Calculator\Calculator.cpp      88      

#include <iostream>
#include <string>

using namespace std;
void addfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den);
void subtractfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den);
void multiplyfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den);
void dividefraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den);

int num1,num2,dent1,dent2,numfrac,denfrac;
int* result_num, result_den;
char operators;
bool choice;

void menu()
{
	cout<<"This Program performs operations on fraction. Enter"<<endl;
	cout<<"1:To add fraction"<<endl;
	cout<<"2:To subtract fraction"<<endl;
	cout<<"3:To multiply fraction"<<endl;
	cout<<"4:To divide fraction"<<endl;
	cout<<"9:To exit the program"<<endl;
}

void addfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den)
{
	result_num = num1 *  dent2 +  num2 * dent1;
	result_den = dent1 * dent2;
}
void subtractfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den)
{
	result_num = num1 *  dent2 -  num2 * dent1;
	result_den = dent1 * dent2;
}
void multiplyfraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den)
{
	result_num = num1 * num2;
	result_den = dent1 * dent2;
}
void dividefraction(int num1, int num2, int den1, int dent2, int& result_num, int& result_den)
{
	if (num1 == 0 || num2 == 0)
	{
		cout<<"sorry you cant divide by zero"<<endl;
		result_num = 0;
		result_den = 0;
	}
	else
	{
		result_num = num1 / dent1;
		result_den = num2 / dent2;

	}


}

int main()
{
while(true)
{
	cout<<"Please Enter a Number one: "<<endl;
	cin>>num1;
	cout<<"Please Enter a Number two: "<<endl;
	cin>>num2;
	cout<<"Please Enter denomenator one: "<<endl;
	cin>>dent1;
	cout<<"Please Enter denomenator two: "<<endl;
	cin>>dent2;
	
	menu();//desplay menu
	cout<<"Please Enter a Operator: "<<endl;
	cin>>operators;
	while (operators != '9')
	{
		switch(operators)
		{
		case '1':
			addfraction(num1, num2, dent1, dent2,  result_num,  result_den);
			break;
		case '2':
			subtractfraction(num1, num2, dent1, dent2,  result_num,  result_den);
			break;
		case '3':
			multiplyfraction(num1, num2, dent1, dent2,  result_num,  result_den);
			break;
		case '4':
			dividefraction(num1, num2, dent1, dent2,  result_num,  result_den);
			break;
		default:
			break;

		}
	}
}
		return 0;
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AndyAinscowFreelance programmer / Consultant

Commented:
int* result_num, result_den;

try this instead
int result_num, result_den;

Author

Commented:
getting this error when i do that
Error 1 error C2664: 'addfraction' : cannot convert parameter 5 from 'int *' to 'int' c:\Users\remote desktop\Documents\Visual Studio 2005\Projects\Calculator\Calculator\Calculator.cpp 79
 
Freelance programmer / Consultant
Commented:
Did you change anything else?  That error message doesn't make sense based on the code you posted and my change

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial