Hi,
So i have written my code to solve the quadratic equation and it works. The thing I need to do is to read values for 3 variables from an input .txt file until the end of the file and output the answers for each set of variables. The variables are a, b, and c. The values in the file are three per line seperated by spaces. Example below.
a b c
1 3 2
1 6 9
3 -2 -1
1 -1 0
1 0 -4
2 2 -2
I am just not sure how to actually go about reading these in line by line. I know i will have to use a loop since the same variables are used over and over again in the function.
Would something like this work? (no formula in yet)
ifstream in_stream;
ofstream out_stream;
in_stream.open(“infile.dat”);
out_stream.open(“outfile.dat”);
int a, b, c;
in_stream >> a>> b>> c;
out_stream << "the three values for this quadratic are”
<< a<<b<<c << endl;
//then i would use them in my function loop
in_stream.close();
out_stream.close();