#include // Write a fraction such as // // 52134/321 // // as an integer plus a fraction whose numerator // is the remainder: // // 52134/321 = 162 + 132/321. // // If the numerator is exactly divisible by the // denominator, the remainder is zero. For example, // // 91/13 = 7 + 0/13. // // Modify the program below so that it displays // the fraction entered by the user in this form. // // You may assume that the user enters a valid // non-negative integer numerator // // 0, 1, 2, 3, 4, ... // // and a valid positive integer denominator // // 1, 2, 3, 4, ... // Function declarations int main(); // Function definitions int main() { int num{}; std::cout << "Enter a non-negative numerator: "; std::cin >> num; int den{}; std::cout << "Enter a positive denominator: "; std::cin >> den; // Modify this statement to produce the desired output. std::cout << num << "/" << den << std::endl; return 0; } // Hint: // // What are the values of // // 52134/321 // // and // // 52134%321 // // when evaluated using integer arithmetic? // // How could you use these two operations to produce // // 52134/321 = 162 + 132/321 // // from the original numerator and denominator? // A solution: /* int main() { int num{}; std::cout << "Enter a non-negative numerator: "; std::cin >> num; int den{}; std::cout << "Enter a positive denominator: "; std::cin >> den; std::cout << num << "/" << den << " = " << (num/den) << " + " << (num%den) << "/" << den << std::endl; return 0; } */