C Program to find the GCD of the given two numbers by using Recursion

#include<stdio.h>

int gcd(int a,int b)
{
 if(b==0)
  return a;
 else
  return gcd(b,a%b);
}

void main()
{
 int x,y;
 printf("Enter any two numbers..");
 scanf("%d%d",&x,&y);
 printf("\nThe gcd of the given two numbers is %d",gcd(x,y));
}

No comments:

Post a comment