Chapter:

Recursive-program-in-c

C Program to find GCD of two Numbers using Recursion

Greatest Common Divisor(GCD) of two numbers is a number that divides both of them.

Below is a program to the GCD of the two user input numbers using recursion.

Source code:

#include<stdio.h>

// declaring the recursive function

int find_gcd(int , int );

int main()

{

    int a, b, gcd;

    printf("\n\nEnter two numbers to find GCD of \n");

    scanf("%d%d", &a, &b);

    gcd = find_gcd(a, b);

    printf("\n\nGCD of %d and %d is: %d\n\n", a, b, gcd);

    return 0;

}

// defining the function

int find_gcd(int x, int y)

{

    if(x > y)

        find_gcd(x-y, y);

 &nbs....Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-