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

please help finish and solve errors for this c language structures program. c la

ID: 659757 • Letter: P

Question

please help finish and solve errors for this c language structures program.

c language. structures. please solve it the most basic way!

1)

Define a structure type to represent a fraction (obviously, there must be two fields: numerator and denominator). Write the following functions

get_fraction, which inputs a fraction and returns it to the caller.

reduce_fraction, which takes a fraction and returns the corresponding fraction reduced to the lowest terms. Hint: Recall and use the gcd (greatest common divisor) function from HW6.

multiply_fractions, which takes two fractions and returns the fraction which is the product (reduced to the lowest terms) of the two factions

divide_fractions, which takes two fractions and returns the fraction which is quotient of the two factions (reduced to the lowest terms)

print_fraction, which takes a fraction and to outputs it.

Write a main function, which uses the functions above to input two fractions, reduce them to the lowest terms, prints resulting fractions, computes their product and quotient, and prints the results.

#include
#include

struct Fraction
{
   int numer; // fields        
   int denom;
};

void     print_fraction(Fraction f);               // prototypes
Fraction add_fractions(Fraction f1, Fraction f2);
Fraction reduce_fraction(Fraction fraction);

int
greatest_common_divisor(int number_1, int number_2)
{
   int gcd = number_1;

   if (gcd > number_2) // assume the GCD starts at the smallest of the two numbers
   {
       gcd = number_2;
   }

   while (gcd > 0)
   {
       if (number_1 % gcd == 0 && number_2 % gdc == 0)
       {
           return gcd;
       }

       gcd--;
   }

   return 0; // no solution

}


Fraction reduce_fraction(const Fraction frac)
{
   // Declare and Initialize the result
   Fraction result = frac; // notice that assignment words for structures

   // find the GCD
   int gcd = greatest_common_divisor(frac.numer, frac.denom);

   while (gcd != 0) // while a GCD exists
   {
       result.numer /= gcd; // divide both the numerator and denominator
       result.denom /= gcd; // by the GCD

       gcd = greatest_common_divisor(result.numer, result.denom); // check for a new GCD

   }

   return result; // you can return a fraction because it is a structure

}

void multiply_frac(Fraction f1, Fraction f2);
{
   numer = f1.numer * f2.numer;
   denom = f1.denom * f2.denom;
}


void div_fract(Fraction f1, Fraction f2);
{
   numer = f1.numer * f2.denom;
   denom = f1.denom * f2.numer;
}

void print_fraction(Fraction f1)
{
   printf("%d/%d", fraction.numer, fraction.denom);

}

Explanation / Answer

numer=1 2

denom=1 2

numer = 2

denom= 2

nemor = 1

denom = 4