Program to find Greatest common divisor of two numbers.(HCF)


source code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include
#include
#include
using namespace std;
 
int main()
{
cout<<"Enter two numbers to find their greatest common divisor : "<
int a,b ,i=1,ans;
cin>>a>>b;cout<<"\n\n\n\n\n";
 
 
while(i
{
   if((a%i==0)&&(b%i==0))
         ans=i;
   i++;
}
cout<<"GCD is "<
getch();
}