Preview:
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{

	cout << "Enter two positive numbers ";
	int n1,n2;
	cin >> n1>>n2;
	int d = 1;
	int gcd = 1;
	
	if (n1 < n2)
		d = n1;
	else
		d = n2;
	while (true)
	{
		if (n1 % d == 0 && n2 % d == 0) {
				gcd = d;
				break;
		}
			
		d--;
	}
	
	cout << "the CGD of " << n1 << " and " << n2 << " is " << gcd;

	
	
		

	
	
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter