GCD program in C || C progamming
In this, we are going to see a program in which it will be finding GCD (Greatest Common Divisor) of two numbers in C Programming Language.

//Write a program to find GCD of Two numbers

#include <stdio.h>

int gcd(int num1, int num2)
{
    if (num2 != 0)
    {
        return gcd(num2, num1 % num2);
    }

    else
        return num1;
}

int main()
{
    int num1, num2;
    printf("Enter two positive integers: ");
    scanf("%d %d", &num1, &num2);
    printf("G.C.D of %d and %d is %d.", num1, num2, gcd(num1, num2));
    return 0;
}


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post