1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
void getdata(ifstream &, int&, int&, int&); // prototype
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
int main ()
{
while (inputFile)
{
getdata(inputFile, valueA, valueB, valueC);
}
void getdata(ifstream &filename,int& numa, int& numb, int& numc);
{
filename >> numa >> numb >> numc;
}
float a, b, c, d, x1, x2;
cout << "\nA quadratic equation is given as: aX^2 + bX + c = 0";
//cin >> a >> b >> c;
d = (b*b) - (4 * a*c);
if (d >= 0)
{
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
cout << "\nThe roots of the quadratic equation are : " << x1 << " and " << x2;
}
else
{
d = d*(-1);
cout << "\nThe roots are imaginary!";
cout << "\nThe roots of the quadratic equation are : " << (-b / (2 * a)) << " + " << (sqrt);
}
}
int getch ();
Put the code you need help with here.
|