#include"iostream"
#include"iomanip"
using namespace std;
int main()
{
int first_number,second_number,gcd;
cout<<"Enter First Number : ";
cin>>first_number;
cout<<"Enter Second Number: ";
cin>>second_number;
for(int i=1;i<=first_number&&i<=second_number;i++)
{
if(first_number%i==0 && second_number%i == 0 )
{
gcd=i;
}
}
cout<<endl<<setw(40)<<"Greatest Common Divison is: "<<gcd<<endl;
system("pause");
}
OUTPUT
#include"iomanip"
using namespace std;
int main()
{
int first_number,second_number,gcd;
cout<<"Enter First Number : ";
cin>>first_number;
cout<<"Enter Second Number: ";
cin>>second_number;
for(int i=1;i<=first_number&&i<=second_number;i++)
{
if(first_number%i==0 && second_number%i == 0 )
{
gcd=i;
}
}
cout<<endl<<setw(40)<<"Greatest Common Divison is: "<<gcd<<endl;
system("pause");
}
OUTPUT
0 Questions:
Post a Comment