I am having difficulty in creating a function for subtracting fractions in a class. I was given this advice to do it
and my attempt is shown below:
Note:subtraction can be achieved by adding (by changing the sign of the numerator - this can be achieved by multiplying it by -1).
but a subtraction seems to come out a little wrong for example the output is:
void Fraction::subtract(Fraction f2, Fraction& f3)
int s_denom = denom * f2.denom ;
int s_num = ((num * -1) * f2.denom) - ((f2.num * -1) * denom);
Can anyone help me to correct this little error.
Enter first numerator: 3
Enter first denominator: 4
Enter second numerator: 2
Enter second denominator: 4
3/4 - 2/4 = -1/4
Thanks if you can.