Reducing fractions program

Hello, im writing a program that takes in a fraction i.e 4/6 and find the gcf of 2 and then outputs 2/3. ive already written some program for this. (so im not expecting evrything to be done for me. but i would like some help on getting it to work. im trying to use Elucids algorithm to find the gcf. but i am having trouble using it. any suggestions would be greatly apprieciated.
[code
//this program will reduce fractions, and output a
//new reduced fraction and the greatest common factor.
#include <iostream.h>

main( )
{
int num, dem;
int frac, rem, reduced;
cout<< "This progam will reduce your fractions."<< '\n';

cout << " Enter the numorator:"<<'\n';
cin >> num;

cout << " Enter the demnomorator:"<<'\n';
cin >> dem;

cout << num <<"/" << dem << " is equal to"<<'\n';

// GCF
frac = num / dem;
dem = 1* num + (frac);
num = 1 * frac + (num / dem);
frac = 1 * (num/ dem) + (frac);
rem = num % dem;

reduced = (num / frac) / (dem / frac);

cout << reduced <<'\n';

system("pause");
return 0;
}
[/code]
Topic archived. No new replies allowed.