Code:

#include "stdafx.h"
#include<iostream.h>
int GetNumber();
int GetSmallest(int, int);
int Factor(int,int, int);
int main()
{
int x, y;
x = GetNumber();
y = GetNumber();
int smallest = GetSmallest(x,y);
int gcf = Factor(x,y,smallest);
cout << "The GCF is: " << gcf << endl;
return 0;
}
int GetNumber()
{
int n;
cout << "Enter a number: ";
cin >> n;
return n;
}
int GetSmallest(int x, int y)
{
if (x > y)
{
return y;
}
return x;
}
int Factor(int x, int y, int smallest)
{
int gcf = 0;
if (x > 0 && y > 0)
{
for(int i = 1; i <= smallest; i++)
{
if(x % i == y % i)
gcf = i;
}
}
return gcf;
}

This seems to work. I tested it a few times. Try it.