Write a program that prompts user to enter a fraction in the formatof numerator/
ID: 3614467 • Letter: W
Question
Write a program that prompts user to enter a fraction in the formatof numerator/denominator, then the program will output the reducedform of the input fraction.a. You need to write a separate function to determine the greatestcommon divisor (GCD) of the denominator and the numerator. Theprototype of finding GCD is as the following:
int gcd(int a, int b);
b. You also need to write a separate function that takes tworeference parameters that refer to the numerator and thedenominator. This function reduces the fraction via the referenceparameters. The function prototype is as the following:
void reduce(int & numerator, int & denominator);
Hint: you need to first find the GCD of numerator anddenominator.
c. Write a main function to test your reduce function with variousinputs (make sure the denominator is not 0).
Example output:
Enter a fraction: 32/48
The reduced fraction is: 2/3
Explanation / Answer
please rate - thanks #include using namespace std; int gcd(int,int); int number(string,int&,char); int main() {string input; int i=0,num1,num2,factor; coutinput; num1=number(input,i,'/'); num2=number(input,i,''); factor=gcd(num1,num2); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.