Skip to content

Instantly share code, notes, and snippets.

@nalin-adh
Created November 10, 2015 17:05
Show Gist options
  • Save nalin-adh/1467d3f38f43a517c4ec to your computer and use it in GitHub Desktop.
Save nalin-adh/1467d3f38f43a517c4ec to your computer and use it in GitHub Desktop.
A C++ program to find GCD of two number using function.
#include<iostream>
#include<conio.h>
using namespace std;
int gcd(int x,int y);
int main()
{
int a,b;
cout<<"Enter two number : ";cin>>a>>b;
cout<<"\nThe GCD of "<<a<<" and "<<b<<" is "<<gcd(a,b);
getch();
return(0);
}
int gcd(int x,int y)
{
int z=x%y;
if(z==0)
return(y);
else
return(gcd(y,z));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment