Quadric Equation

Write your question here.
Need Help!
I have to write a program that solve the quadric equation for x the program has to open and get data from a file. Here is the code that I have written so far the code will not compile.
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.
Last edited on
he code will not compile

No offence but this isn't very helpful. If your compiler is giving you errors they will give you a hint of what's wrong.

For example, I can see on line 14 you have:
while (inputFile)
but you haven't declared a variable called inputFile

You are also putting function implementation inside your main function, which is wrong (line 20). This needs to be moved out.
Last edited on
Topic archived. No new replies allowed.