### Calculator

I am getting the following error:

1>Calculator.obj : error LNK2019: unresolved external symbol "void __cdecl divideFractions(int,int,int,int,int &,int &)" (?divideFractions@@YAXHHHHAAH0@Z) referenced in function _main

it doesn't say what line number this is occurring on and to be honest i don't know what it means... any help would be appreciated...

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136`` ``````#include #include using namespace std; char menu(); void addFractions( int a1, int b1, int a2, int b2, int& num, int& den ); void subtractFractions( int a1, int b1, int a2, int b2, int& num, int& den ); void multiplyFractions( int a1, int b1, int a2, int b2, int& num, int& den ); void divideFractions( int a1, int b1, int a2, int b2, int& num, int& den ); int main() { int a1, b1, a2, b2, num, den; char ch = menu(); try { cout << "\n\tEnter the numerator of the fraction 1: "; cin >> a1; cout << "\tEnter the denominator of fraction 1: "; cin >> b1; if ( b1 == 0 ) throw b1; else if( b1 < 0 ) { string s = "Negative denominator exception"; throw s; } cout << "\n\tEnter the numerator of fraction 2: "; cin >> a2; cout << "\tEnter the denominator of fraction 2: "; cin >> b2; if( b2 == 0 ) throw b2; else if( b2 < 0 ) { string s = "Negative denominator exception"; throw s; } switch( ch ) { case '+': addFractions( a1, b1, a2, b2, num, den ); cout << "\n\tThe sum of the fractions is" << num << "/" << den; break; case '-': subtractFractions( a1, b1, a2, b2, num, den ); cout << "\n\tThe difference of the fraction is " << num << "/" << den; case '*': multiplyFractions( a1, b1, a2, b2, num, den ); cout << "\n\tThe product of the fractions is " << num << "/" << den; case '/': if( a2 != 0 ) { divideFractions( a1, b1, a2, b2, num, den ); cout << "\n\tDivision of the fractions is " << num << "/" << den; } else cout << "\n\tDenominator fraction cannot be zero."; break; } } catch( int x ) { cout << "Denominator is " << x << "exception" << endl; } catch( string s ) { cout << s; } cout << endl; system( "pause" ); return 0; } char menu() { char operationType; cout << "\n\n\tProgram that lets the user perform " << endl; cout << "arithmetic operations on fractions." << endl; cout << "\n\n\t\t M E N U"; cout << "\n\nAddition :+"; cout << "\n\tSubtraction :-"; cout << "\n\tMultipication :*"; cout << "\n\tDivision :/"; cout << "\n\n\tEnter operation to perform: "; cin >> operationType; return operationType; } void addFractions( int a1, int b1, int a2, int b2, int& num, int& den ) { num = ( a1 * b2 ) + ( b1 * a2 ); den = b1 * b2; } void subtractFractions( int a1, int b1, int a2, int b2, int& num, int& den ) { num = ( a1 * b2 ) - ( b1 * b2 ); den = b1 * b2; } void multiplyFractions( int a1, int b1, int a2, int b2, int& num, int& den ) { num = a1 * a2; den = b1 * a2; }``````
When I compiled it, I got

 ```Undefined symbol first referenced in file divideFractions(int, int, int, int, int&, int&) ld: fatal, ld returned 1 exit status.```

So there is a problem with your `divideFractions` function. It is either with your declaration in the main function or in the function itself, which I see you did not list as part of your code.
Hey Pal,
you didn't give definition of your function divideFractions()..
Topic archived. No new replies allowed.