728x90 AdSpace

Latest Article

Find GCD using Rescrsive Function in c++ example code




How to implement the GCD function using Rescrsive Function in c++ source code

# include <iostream.h>
# include <conio.h>
# include <math.h>

int gcd(int,int) ;


void main()
 {
   int a,b;
   cout << "\n Enter first integers:" ;
   cin  >> a;
   cout << "\n Enter second integer:" ;
   cin  >> b;
   cout << gcd(a,b);
   getch();
   }

int gcd(int x,int y)
 {
   if(x<y)
    {
      return gcd(y,x);
      }

   else
    {
      if (x%y==0)
       return y;

      gcd(y,(x%y));
      }
   }
no image





  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top