Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone please correct my error, I can\'t get my program to run. Thanks! #in

ID: 3542511 • Letter: C

Question

Can someone please correct my error, I can't get my program to run. Thanks!


#include <iostream>
using namespace std;

double den(double x, double y)
{
    return (x*y);
}
double num(double a, double b, double c, double d, double e)
{
    e=b*d;
    a=(e/b)*a;
    c=(e/d)*c;
    return a+c;
}

int main()
{
    double a,b,c,d,e;
    char s,t;

    cout<<"Please enter two fractions i.e. (a/b)+(c/d): ";
    cin>>a>>s>>b>>t>>c>>d;
    cout<<"The sum is"<<num(a, b, c, d, e)<<"/"<<den(b, d)<<endl;
    system("pause");
    return 0;
}


Explanation / Answer

Assign a value to e

i.e

change

cin>>a>>s>>b>>t>>c>>d;

to

cin>>a>>s>>b>>t>>c>>d>>e;