hi guys, i need help adding subtracting multiplying and dividing fractions that the user enters into a code. here is what i have so far, but when i run it, the numbers come out to 0 plus 0 = 0. i havent started on the other mathematical operations yet. any ideas how to make this work? i am supposed to use a switch structure to process the menue choices but idk what thatis. heere is my code:
#include <iostream>
using namespace std;
#include <cmath>
int main()
{
int num;
int den;
int x;
int y;
char slash;
Make the input two pairs of integers, each pair separated by a '/'.
Call them a,b,c and d.
Now use grade-school math:
a/b+c/d=(ad+cb)/bd
a/b-c/d=(ad-cb)/bd
(a/b)*(c/d)=(ac)/(bd)
(a/b)/(c/d)=(ad)/(bc)
if you want to operate on a number of fractions in a continuous manner use a loop and obtain the Lowest Common Multiple of the denominators as each new fraction is entered.