Answers for "fraction sum c"

C
0

fraction sum c

/** Struct describing a Fraction */
typedef struct Fraction
{
    int num; // numerator
    int den; // denominator
} Fraction;

Fraction frc_sum(Fraction a, Fraction b)
{
    const int lcm = frc_lcm(a,b);

    Fraction f = {(a.num * lcm/a.den) + (b.num * lcm/b.den), lcm};
    //frc_simplify(&f);

    return f;
}

// IN MAIN
Fraction f1 = {1,3};
Fraction f2 = {1,6};
frc_print(frc_sum(f1, f2));
Posted by: Guest on March-11-2022

Code answers related to "C"

Browse Popular Code Answers by Language