Answer to Question #91255 in C++ for matimu

Question #91255
Write a function named "g_c_d" that takes two positive integer arguments and returns as its value the
greatest common divisor of those two integers. If the function is passed an argument that is not positive (i.e.,
greater than zero), then the function should return the value 0 as a sentinel value to indicate that an error
occurred. Thus, for example,
cout << g_c_d(40,50) << endl; // will print 10
cout << g_c_d(256,625) << endl; // will print 1
cout << g_c_d(42,6) << endl; // will print 6
12
cout << g_c_d(0,32) << endl; // will print 0 (even though 32 is the g.c.d.)
cout << g_c_d(10,-6) << endl; // will print 0 (even though 2 is the g.c.d.)
1
Expert's answer
2019-07-01T01:13:31-0400
Dear matimu, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS