Write a program that inputs two numbers and displays the greatest common divisor of both numbers.

Write a program that inputs two numbers and displays the greatest common divisor of both numbers.



#include<iostream>
using namespace std;
int main ()
{
int a,b,i,g;
cout<<"\t * GCD Calculator * "<<endl;
cout<<"\n";
cout<<"Enter the First Number"<<endl;
cin>>a;
cout<<"Enter the Second Number"<<endl;
cin>>b;
for (i=1; i<=a && i<=b; i++)
{
if(a%i==0 && b%i==0)
{
g=i;
}
}
cout<<"\n";
cout<<"GCD of given numbers is = "<<g<<endl;
}


Write a program that inputs two numbers and displays the greatest common divisor of both numbers.