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