Im considering writing a C++ program that can add, subtract, multiply or divide
ID: 3569420 • Letter: I
Question
Im considering writing a C++ program that can add, subtract, multiply or divide two fractions.While Keeping it simple.I wanna write some with functions such as "fetchFraction", "addFraction", "subtractFraction" (although remember the indirect function methods ) "reduceFraction", "showFraction", and whatever else i need. Keep things modular: divideFraction might simply invert the secondly submitted fraction, then send that result to multiplyFraction for instance. All fractions should be sent to findCommonDenominator if being added or subtracted, and reduceFraction for any fraction before showing the result.I want too think about the structure of both a Class and the program itself here with nice comments to follow along.
Explanation / Answer
#include #include using namespace std; struct Fraction { int numerator; int denominator; }; int addition(int num1, int den1, int num2, int den2) { int n1, d1, n2, d2, result; result = ((n1)/(d1)) +((n2) + (d2)); return result; } int main(int argc, char *argv[]) { int sum, difference, product, quotient; Fraction sFract1; sFract1.numerator; sFract1.denominator; Fraction sFract2; sFract2.numerator; sFract2.denominator; cout > sFract1.numerator; cout > sFract1.denominator; cout > sFract2.numerator; cout > sFract2.denominator; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.