Question
write code using void function

visor (GCD) of two integers is the largest nacd that returns the greatest com- its digits reversed. For example, 5.31 (Greate

i need the code in C++ but make sire u solve by using void function
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the details below:

#include <iostream>

using namespace std;

void greatestcommondivisor()

{

    int firstNumber,secondNumber,gcd,i;

    cout << " Enter the First Number :";

    cin >> firstNumber;

    cout << " Enter the Second Number : ";

    cin >> secondNumber;

    for (i = 1; i <= firstNumber && i <= secondNumber; i++)

    {

        if (firstNumber % i == 0 && secondNumber % i == 0)

        {

            gcd = i;

        }

    }

    cout << " The Greatest Common Divisor of " << firstNumber << " and " << secondNumber<< " is: " << gcd << endl;

}

int main()

{

    greatestcommondivisor();

}

Add a comment
Know the answer?
Add Answer to:
write code using void function i need the code in C++ but make sire u solve...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I want the code in C++ The greatest common divisor (GCD) of two integers is the...

    I want the code in C++ The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the numbers. Write a function called GCD that has a void return type, and accepts 3 parameters (first two by value, third by reference). The function should find the greatest common divisor of the first two numbers, and have the result as its OUTGOING value. Write a main function that asks the users for two integers, and...

  • IN PYTHON Write a recursive function for Euclid's algorithm to find the greatest common divisor (gcd)...

    IN PYTHON Write a recursive function for Euclid's algorithm to find the greatest common divisor (gcd) of two positive integers. gcd is the largest integer that divides evenly into both of them. For example, the gcd(102, 68) = 34. You may recall learning about the greatest common divisor when you learned to reduce fractions. For example, we can simplify 68/102 to 2/3 by dividing both numerator and denominator by 34, their gcd. Finding the gcd of huge numbers is an...

  • C++ I do not understand this problem. 14THE GREATEST COMMON DENOMINATOR PROBLEM Write a function named...

    C++ I do not understand this problem. 14THE GREATEST COMMON DENOMINATOR PROBLEM Write a function named god() that accepts two integers as input parameters and returns the greatest common divisor of the two numbers. The greatest common divisor (GCD) of two integers, a and b, is the largest integer that is a factor of both a and b. The GCD of any number and 1 is 1, and the GCD of any number and o is that number. One efficient...

  • coding in c programming Functions & Arrays Q1) The greatest common divisor (GCD) of two Integers...

    coding in c programming Functions & Arrays Q1) The greatest common divisor (GCD) of two Integers (of which at least one is nonzero) is the largest positive integer that divides the numbers. Write a C function ged that accepts two integers and returns 1 if both the integers are zero, otherwise it returns their GCD. Write a C program (that includes the function ged) which accepts two integers and prints their GCD. Sample output: Enter two integers: 0 0 At...

  • Using Python!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a pair...

    Using Python!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a pair of numbers. The gcd of m and n is the largest number that divides both m and n. If one of the numbers is 0, then the gcd is the other number. If m is greater than or equal to n, then the gcd of m and n is the same as the gcd of n and m-n. If n is greater than m,...

  • Using SPIM, write and test a program that finds the Greatest Common Divisor of two integers...

    Using SPIM, write and test a program that finds the Greatest Common Divisor of two integers using a recursive function that implements Euclid's GCD algorithm as described below. Your program should greet the user "Euclid's GCD algorithm", prompt the user to input two integers, and then output the result "Euclid's Greatest Common Divisor Algorithm" GCD(M,N) = M                      (if N is 0) GCD(M,N) = GCD(N, M % N)   (if N > 0) you may assume that inputs are non-negative name your assembly...

  • Must be written in C. Complete the implementation of the gcd function using recursion: int gcd(int...

    Must be written in C. Complete the implementation of the gcd function using recursion: int gcd(int a, int b); the function computes the greatest common divisor. The greatest common divisor represents the largest common divisor between two numbers. For example, the greatest common divisor between 28 and 63 is 7, because 7*4=28, and 7*9=63, and 28 and 63 share no common larger divisor. Must use recursion in your solution. Need to handle negative inputs appropriately. For example, the gcd of...

  • Extended Euclidian Algorithm (page 4 of last lecture, more on algorithms) Write code that asks for...

    Extended Euclidian Algorithm (page 4 of last lecture, more on algorithms) Write code that asks for and gets two integers, then computes and displays their greatest common divisor using the Extended Euclidian Algorithm (EEA). The EEA should be implemented as a function that takes two integers are arguments and prints their GCD.

  • PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer...

    PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer that divides the two numbers without a remainder. For example, the GCD of 8 and 12 is 4. Steps to calculate the GCD of two positive integers a,b using the Binary method is given below: Input: a, b integers If a<=0 or b<=0, then Return 0 Else, d = 0 while a and b are both even do a = a/2 b = b/2...

  • Write a C++ program that reads in two integers and then computes the greatest common divisor...

    Write a C++ program that reads in two integers and then computes the greatest common divisor GCD using recursion. DO NOT USE A BUILT-IN FUNCTION SUCH AS "gcd" to do this.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT