Created
November 10, 2015 17:05
-
-
Save nalin-adh/1467d3f38f43a517c4ec to your computer and use it in GitHub Desktop.
A C++ program to find GCD of two number using function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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