C program to find the GCD (Greatest Common Divisor) of given numbers using recursion
belongs to collection: C Programming Recursion Examples, Programs
All Answers
total answers (1)
belongs to collection: C Programming Recursion Examples, Programs
total answers (1)
Read two integer numbers, and find the GCD (Greatest Common Divisor) of given numbers.
Program:
The source code to find the GCD (Greatest Common Divisor) of a given number using recursion is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
In the above program, we created two functions calGCD() and main(). The calGCD() function is a recursive function, which is used to find the Greatest Common Divisor of specified numbers.
In the main() function, we read two integer numbers num1 and num2 from the user and called calGCD() function, and printed the GCD of given numbers on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer