Hi, I'm using Microsoft Visual C++ and I keep getting this error referring to this one line in my main file. The line of error is in bold.
Header file
int f (int n);
double e (double accuracy);
double exp (double expo, double exaccuracy);
Computation file
#include "wong_header.h"
int f(int n)
{
int t = 1;
while (n >= 1)
{
t = t * n--;
}
return t;
}
double e (double accuracy)
{
accuracy = accuracy - 1;
double fac = 1;
double ee = 0;
while (accuracy >= 1)
{
fac = fac * accuracy;
ee = ee + (1/(fac));
accuracy--;
}
return ee;
}
double exp (double expo, int exaccuracy)
{
exaccuracy = exaccuracy - 1;
double value;
double fact = 1;
double exo = 0;
while ((expo >=0)&&(exaccuracy >=1))
{
value = expo * exaccuracy;
fact = fact * exaccuracy;
exo = exo + (value/fact);
exaccuracy--;
}
return exo;
}
main file
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
using namespace std;
#include "wong_header.h"
int main()
{
string command;
int arg1;
double earg2;
double exarg4, exarg5;
int result;
double eresult, exresult;
ifstream fin ("input.txt"); //reads from file input.txt
if (!fin) //checks input file
{
cerr <<"Cannot open the file input.txt\n";
return 0;
}
ofstream fout("out.txt"); //output stream
if (!fout) //check if output file
{ //was opened successfully
cerr <<"Cannot open the file out.txt\n";
return 0;
}
while(!fin.eof()) //it will read line after line until the program ends
{
fin >> command;
int f = atoi (command.c_str());
if (command == "f")
{
fin >> arg1;
[B]result = f(arg1);[/B]
cout << "factorial of " << arg1 << "= " << result << "\n";
fout << "factorial of " << arg1 << "= " << result << "\n";
}
else if (command == "!")
{
}
else if (command == "e")
{
fin >> earg2;
eresult = e(earg2);
cout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
fout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
}
else if (command == "exp")
{
fin >> exarg4, exarg5;
exresult = exp(exarg4, exarg5);
cout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
cout << exresult <<"\n";
fout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
fout << exresult <<"\n";
}
else
{
}
}
fin.close();
fout.close();
return 0;
}
Can someone help me figure out what I'm doing wrong?