Quantcast
Channel: Java Question Bank » Cpp Programs
Viewing all articles
Browse latest Browse all 22

A ‘C++’ PROGRAM TO FIND THE G.C.D OF TWO NUMBERS USING RECURSIVE FUNCTIONS

$
0
0

****************************************************************************************************************************************************

A ‘C++’ PROGRAM TO FIND THE G.C.D OF TWO NUMBERS USING RECURSIVE FUNCTIONS

***************************************************************************************************************************************************

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream.h>
#include<conio.h>
int gcd(int m,int n)
{
if(n==0)
return m;
else
return gcd(n,m%n);
}
void main()
{
int m,n;
clrscr();
cout<<"Enter m,n values :";
cin>>m>>n;
cout<<"The G.C.D of given two numbers :"<<gcd(m,n);
getch();
}

/*    OUTPUT
------
Enter m,n values :24 6
The G.C.D of given two numbers :6
*/

45 total views, 1 views today


Viewing all articles
Browse latest Browse all 22

Trending Articles