Write a function - greatest common divisor

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

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: EM13872209

Questions Cloud

Prepare the journal entries to record acquisition of mining : Prepare the journal entries to record the acquisition of the mining equipment and the asset retirement obligation for the mine on January 1, 2014.
How the sequential and additive composition adaptors differ : how the sequential and additive composition adaptors differ
Demonstration before the noblemen : In 1654 Otto von Guericke, inventor of the air pump gave a demonstration before the noblemen of the Holy Roman Empire in which two teams of eight horses could not pull apart two evacuated brass hemispheres.
Fluid property having dimensions : If V is a velocity, l a length and v a fluid property having dimensions of L2T-1, which of the following combinations are dimensionless:
Write a function - greatest common divisor : 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.
Molecules of the first be heavier : If one material has a higher density than another, must the molecules of the first be heavier those of the second? Explain
What is the trignomerty leveling : What is the trignomerty leveling? Explain in detail.
Drag force on the bubble is negligible : If a bubble in sparkling water accelerates upward at the rate of 0.225 m/s2 and has a radius of 0.500 mm, what is its mass? Assume that the drag force on the bubble is negligible.
Trend reports on the topic information technology : Write five trend reports on the topic Information Technology & business starting with January-December 2015 (nothing earlier) in hard (paper) and soft (electronic file)

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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