Hello!
So.. Basically what my file is trying to do is to open a .txt file, read it and then solve the quadratic equation with numbers from the .txt file. Now I realize that I'm probably doing some parts wrong, and I'm fine with that.
My problem is that every time I run the program, a debug error occurs stating that 'b' is being used without being initialized. I've defined it, so I'm not sure why the computer is having such a problem.
#include<iostream>
#include<fstream>
#include<cmath>
usingnamespace std;
int main ()
{
ifstream quad;
quad.open ("N:\CS140\Week 6\quad.txt");
double a, b, c, root1, root2;
root1 = (b + sqrt(b*b-4*a*c))/(2*a);
root2 = (b - sqrt(b*b-4*a*c))/(2*a);
if (quad.is_open())
{
cout << quad << endl;
cout << "Choose a set of numbers and enter them:";
cin >> a >> b >> c;
}
if (quad.fail ())//used if quad.txt doesn't open.
{
cerr <<"The file 'quad.txt' could not be opened."<<endl;
}
}//end main