Find GCD using recursion | C program
Write a C Program to find GCD of two user given number using recursion , C program :
Code:
#include<stdio.h>
void main()
{
int gcd(int ,int);
int n,b,a;
printf("Enter two number:\n");
scanf("%d%d",&a,&b);
n=gcd(a,b);
printf("%d",n);
}
int gcd(int a,int b)
{
if(a==b)
return a;
else if(a%b==0)
return b;
else if(b%a==0)
return a;
else if(a>b)
return(gcd(a%b,b));
else
return(gcd(a,b%a));
}

Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)