FRACTION SIMPLIFIER
The following fraction simplifier program accepts a fraction, simplifies it, and then displays the result. Your task is to complete this program.
Your solution declares a Fraction type, which holds the numerator and denominator as separate members and includes the definitions of three functions with the following prototypes
• void enter(struct Fraction*);
• void simplify(struct Fraction*);
• void display(const struct Fraction*);
Complete the following program by adding the missing code:
// Fraction Simplifier
// w9.c
#include <stdio.h>
// insert Fraction declaration first
// insert function prototypes here
int main(void)
{
struct Fraction f;
printf("Fraction Simplifier\n");
printf("===================\n");
enter(&f);
simplify(&f);
display(&f);
}
// insert your function definitions here
The output from your completed program looks something like
Fraction Simplifier
===================
Numerator: 4
Denominator: 16
1 / 4
Your enter() function receives the address of a Fraction object, accepts from the user the numerator and denominator and stores those values in the object's members.
Your simplify() function receives the address of a Fraction object and reduces the numerator and denominator, if possible. For a complete solution you need to design an algorithm that simplifies a fraction.
Your display() function receives the address of a Fraction object and displays the object's numerator and denominator.
Test several fractions to ensure that your algorithm works for all cases. Include negative as well as zero values in your test cases.
Done
//////////////////////
Second job attached as word document.