Hi there, this is my GCD profile. I have written the recursive and iterative functions so far. But my assignment also requires me to write a output file. The Visual studio have already created an output file for me but there is nothing in it. I'm so confused because my functions have already succeed. Thanks for your help!
[code]
int Mul_sub(int x, int y)
{
int temp = 0;
if ((x%y) == 0)
{
temp = y;
}
else
{
temp = Mul_sub(y, x%y);
}
return temp;
}
int gcd(int a,int b)
{
if (b == 0)
return a;
else
return gcd(b, a%b);
}
int main()
{
int first_num;
int second_num;
}
ifstream fin;
ofstream fout,
errOut;
fin.open("Input.dat");
fout.open("Output.dat");
if (fin.fail())
{
cout << "Error Opening the file" << endl;
cin >> exit;
}
for (; fin >> first_num >> second_num;)
{
if (first_num < second_num)
{
cout << "**Error(line 2): "<<first_num<<" is not greater than "<< second_num << endl;
noErrors = false;
continue;
}
}
fout << "Given the input numbers " << first_num << " and " << second_num << ", the GCD" << endl;
fout << " as computed by the recursive function is" << Mul_sub(30, 20) << endl;
fout << " as computed by the iterative function is" << gcd(45, 15) << endl;
fout << "Given the input numbers " << first_num << " and " << second_num << ", the GCD" << endl;
fout << " as computed by the recursive function is" << Mul_sub(45, 15) << endl;
fout << " as computed by the iterative function is" << gcd(45, 15) << endl;
fout << "Given the input numbers " << first_num << " and " << second_num << ", the GCD" << endl;
fout << " as computed by the recursive function is" << Mul_sub(15, 15) << endl;
fout << " as computed by the iterative function is" << gcd(15, 15) << endl;
fout << "Given the input numbers " << first_num << " and " << second_num << ", there is no GCD" << endl;
fout.close();
/code]