Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q6. Design an algorithm and write its C++ code. It takes two positive integer arguments, call them,m and n, treats them as the numerator and

image text in transcribed

Q6. Design an algorithm and write its C++ code. It takes two positive integer arguments, call them,"m" and "n", treats them as the numerator and denominator of a fraction, and reduces the fraction. That is to say, each of the two arguments will be modified by dividing it by the greatest common divisor of the two integers. The function should return the valuen (to indicate failure to reduce) if either of the two arguments is zero or negative, and should return the value 1 otherwise. Thus, for example, ifm' and 'n' have been declared to be integer variables in a program, then. Thus, for example: m = 63; n = 210; will produce and print 3/10' m = 25; n = 0; will produce and print Fractional Error' Keep your code commented and indented for ease of reading. Paste your commented codes in the solution and also add a clear screen shot of outcome in your solution: (3.0-Mark)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions