Write a C program to solve the Greatest Common Divisor, according to the brute-force

The output should appear as the following example:

1st number = 37
2nd number = 11
The GCD of 37 and 11 is 1.
Press any key to continue_

thank you,

Write a C program to solve the Greatest Common Divisor, according to the brute-force

The output should appear as the following example:

1st number = 37
2nd number = 11
The GCD of 37 and 11 is 1.
Press any key to continue_

thank you,

``````#include <iostream>

int main()
{
int a,b;

std::cout << "This is application solve for GCD between two numbers";
std::cin >> a;
std::cin >> b;

std::cout << "The first number is = " << a << std::endl;
std::cout << "The second number is = " << b << std::endl;

std::cin.clear();
std::cin.sync();

if(a>b)
{
if(a%b == 0)std::cout << "The GCD = " << b << std::endl;
else{
while(a%b!=0)
{
int c = a%b;
a = b;
b = c;
}
std::cout << "The GCD = " << a << std::endl;
}
}
if(a<b)
{
if( b%a == 0)std::cout << "The GCD = " << a << std::endl;
else{
while(b%a!=0)
{
int c = b%a;
b = a;
a = c;
}
std::cout << "The GCD = " << b << std::endl;
}
}
if(a == b)std::cout << "The GCD = " << a << std::endl;

std::cout << "Press any key to exit" << std::endl;

std::cin.get();
return 0;
}``````

by Weichen