Write a function that takes two positive integer arguments

Assignment Help C/C++ Programming
Reference no: EM13339021

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
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.)

Reference no: EM13339021

Questions Cloud

What is current in the loop when the torque is at max value : The loop consists of a single turn of flexible conducting wire that is wrapped around a flexible mount such that the dimensions of the rectangle can be changed.
How far downstream does the canoe land : If the river current is 2 m/s (from left to right) and the canoe is moving at 5m/s toward the upper shore at a 60° angle, how far downstream does the canoe land
What is the angular velocity of the turntable : A coin rests 14.0 cm from the center of a turntable. The coefficient of static friction between the coin and turntable surface is 0.440. what is the angular velocity of the turntable
Compare difference between insolation on north and south : Compare the difference between the insolation on the north and south faces in each session with the seasonal variation on each face. Ignore eccentricity and atmospheric absorption.
Write a function that takes two positive integer arguments : 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).
Compute the constant angular acceleration of the centrifuge : A centrifuge in a medical laboratory rotates at an angular speed of 2000 rev/ min. Find the constant angular acceleration of the centrifuge
Seriously compared to the ancient world : Seriously compared to the ancient world?
Sketch frequency spectrum representing a harmonic vibration : sketch the frequency spectrum representing a harmonic vibration of frequency 10v, modulated harmonically at a frequency v.
At what angle to the normal does the ray enter the water : A ray of light is incident on the outer glass wall of an aquarium which have a refractive index of 1.51. If the reflected portion of the light is completely polarized at what angle to the normal does the ray enter the water

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a website that would allow users to enter and submit

Create a Website that would allow users to enter and submit survey

  Write c++ program that reads in the average monthly rainfall

Write a C++ program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months

  Iterative programming problem solving approaches

Write a recursive function void reverse ( ) that reverse a sentence

  Write a function to arrange 10 numbers stored in an arraye

Writ a funtion to arrange 10 numbers stored in an array forom the largest to the smallest and pass the results to main program.

  Program which calculates the average and sum of the numbers

write down a program which calculates the average and sum of the numbers enter by a user.Using a While Loop

  Write a function num_digits(n)

C programing, not C++ write a function num_digits(n) that returns the number of digits in a nonnegative integer n.

  Write a very basic doubly-linked list

CptS 122 Lab #2: Linked Lists ,  Along with vectors, linked lists are one of the fundamental data structures in computer science. Unlike vectors, which store information in a contiguous block of computer memory, linked lists have the potential to sto..

  Ohio phonebook has gotten mixed up

In an accident, the Ohio phonebook has gotten mixed up. The names are now really out of order. You and your enthusiastic, but naive, assistant Carl must fix the problem. No one can use the phonebook while you are sorting it, so every extra second of ..

  Create a customer profile class.

a. Create a CustomerProfile class. Each CustomerProfile contains a last name, phone number, and bit fields indicating whether the customer:

  Modify the catch block in method2

Modify the catch block in Method2 that catches the TestException so that it displays the original cause of the exception. Compile and run the application to make sure it works.

  Why does the neverwet spray protect it from water

As is know, acetone is a polar molecule like water, so isn't it suppose to mix? So my question is: why does the Neverwet spray protect it from water but not from oils and detergents?

  Reads a set of integers from file

The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd