Answered step by step
Verified Expert Solution
Question
1 Approved Answer
x Canvas 4 X COB -Windows: controlta (mark), control+c (copy), control+v(paste) -MAC:cmdta (mark), cmd+c (copy).cmdtv (paste) Question 1 8 pts (8 marks) Write a CH+
x Canvas 4 X COB -Windows: controlta (mark), control+c (copy), control+v(paste) -MAC:cmdta (mark), cmd+c (copy).cmdtv (paste) Question 1 8 pts (8 marks) Write a CH+ program that takes two positive integers from an interactive user, call them "num" and "denom", treats them as the numerator and denominator of a fraction, and reduces the fraction by dividing numerator and denominator by the greatest common divisor of the two integers (i.e., the largest positive integer that divides each of the integers). The program should display a message "fraction error" to indicate failure to reduce if either of the two arguments is zero or negative, and should display the fraction after reduction otherwise. For example, if num and denom have been declared to be integer variables in the program, then int num = 9; int denom = 6; The program will produce the following output: 3/2 The program will display the same fraction if there is no common divisor. Hint: for successful output use, cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started