Write a simple program that takes in a numerator and denominator and then computes the GCD for that fraction. You can assume that there is a GCD for any fraction entered. Once you have found the GCD, print the original fraction and the fraction reduced with the GCD to the command line. To get full credit for this assignment, you must use iteration. java

Respuesta :

A simple program that takes in a numerator and denominator and then computes the GCD for that fraction is Enter your and then Enter your denominator: zero Invalid input, denominator can't be zero.

What is numerator and denominator in programming?

  1. Enter your denominator: zero Invalid input, denominator can't be zero.
  2. Enter your denominator: 3
  3. The lowest phrases of your fraction: 34/3
  4. Enter your denominator: 6.
  5. The lowest phrases of your fraction: 1/2
  6. ++ Code

  1. # include
  2. # include
  3. the use of namespace std;
  4. // Function to calculate GCD
  5. int g_c_d(int num1, int num2)
  6. go back num2;
  7.   if (num2 == 0)
  8. go back num1 if (num1 == num2)
  9. go back num1;
  10. // Function to lessen to fraction to lowest phrases
  11. bool to_lowest_terms(int &numerator, int &denominator)
  12. {
  13. if (denominator == 0)
  14.   if (numerator == 0)
  15.  cout << "nThe lowest phrases of your fraction: " << 0 xss=removed> 0 && denominator > 0);
  16. numerator = abs(numerator);
  17. denominator = abs(denominator);
  18. int factor = g_c_d(numerator, denominator)

Read more about GCD :

https://brainly.com/question/219464

#SPJ1