i am working on a fraction calculator using functions and i'm stuck. when i compile my code i get an error that says function fracDiv cannot take 0 parameters... can anyone help? here's my code so far:
Code:
#include <iostream>
using namespace std;
//Function prototype: fracDiv
//--------------------------------------------------------------------
// Function: fracDiv
// Purpose: Divide two fractions and receive the output as a fraction
// a/b / c/d = (a*d) / (b*c)
// Preconditions: parameters: a (int, numerator of first fraction, value parameter)
// b (int, denominator of first fraction, value parameter)
// c (int, numerator of second fraction, value parameter)
// d (int, denominator of second fraction, value parameter)
// num (int, numerator of result, reference parameter)
// den (int, denominator of result, reference parameter)
//
// Postconditions: Returns: int--0 if calculation can be performed,
// 1 if denominator of first fraction is zero
// 2 if denominator of second fraction is zero
// 3 if numerator of second fraction is zero
// num contains numerator of result
// den contains denominator of result
//
int fracDiv(int a, int b, int c, int d, int& num, int& den);
int main()
{
int numerator, denominator;
int a = 0;
int b = 0;
int c = 0;
int d = 0;
cout << "Enter two fractions: " << endl;
cin >> a >> b >> c >> d;
fracDiv(numerator, denominator);
cout << "Answer = " << numerator << "/" << denominator << endl;
return 0;
}
//Function
int fracDiv(int a, int b, int c, int d, int& num, int& den)
{
num = a * d;
den = b * c;
return 0;
}