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

Please help with c language program. we are learning structures so I\'m suppose

ID: 659734 • Letter: P

Question

Please help with c language program. we are learning structures so I'm suppose to use structures. this is all one question/

#include <stdio.h>

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.

Explanation / Answer

/*! ___STANDARD INCLUDES_____________________________________________________ */ #include /*! ___PROJECT INCLUDES______________________________________________________ */ #include "fractionsQ2.h" int GCD(int n1, int n2){ return 1; } void Reduce(fraction *f){ int commonFactor; } int CreateFraction(int numerator, int denominator, fraction *f){ return 1; } int DisposeFraction(fraction *f){ return 1; } int AddFractions(fraction f1, fraction f2, fraction *result){ int numerator, denominator; return 1; } int SubtractFractions(fraction f1, fraction f2, fraction *result){ int numerator, denominator; return 1; } int MultiplyFractions(fraction f1, fraction f2, fraction *result){ int numerator, denominator; return 1; } int DivideFractions(fraction f1, fraction f2, fraction *result){ int numerator, denominator; return 1; } int IsDigit(char ch){ return 0; } void SkipBlanks(char *s, int *index){ } void GetNumber(char *s, int *index, int *number){ } char AssignFraction(char negative, int whole, int num, int denom, fraction *f){ char success; return 1; } int StringToFraction(char *s, fraction *f){ int index, firstNum, secondNum, thirdNum; char negative; return 0; } /*! *************************************************************************** Parameters: num - a number. s - a pointer to a string index - the index into s Returns: nothing. Description: Convert num into a sequence of digit characters that are assigned to the string at position index. Notes: *******************************************************************************/ void ConvertNumber(int num, char *s, int *index){ int digit; } /*! *************************************************************************** Parameters: f - a pointer to a fraction. properFraction - an indication how the fraction should be printed. s - the resulting string. Returns: 1 on success, else 0. Description: Convert the fraction f to string format either as a mixed number, such as 2 1/5, or as an improper fraction, such as 11/5, depending on the boolean parameter properFraction. Notes: *******************************************************************************/ int FractionToString(fraction f, char properFraction, char *s){ int index, wholeNumber, numerator; return 1; } /*! *************************************************************************** Parameters: f - a pointer to a fractrion. Returns: a float with the value of f. Description: Convert fraction f to the corresponding float number. Notes: *******************************************************************************/ float FractionToFloat(fraction f){ return 0.0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote