quadratic

would someone please test my program on there computer it is working on mine but not on my teachers.


#include<iostream>
#include<cmath>
using namespace std;

int main ()
{

cout <<"Pledge: On my honor, I have neither given nor received unauthorized aid\n";
cout <<"on this assignment. I have not designed this program\n";
cout <<"in such a way as to interfere with the normal\n";
cout <<"operation of the D.C.C./ instructor's computer\n";

cout <<"Student name: Todd Hobza II";
cout <<"File name: q 2.0";
cout <<"Description: this program finds the 2 roots to a quadradic equadion";
cout <<"Course: egr 126 01";
cout <<"Date: 9/29/2013";
system("pause");

float a, b, c, r_1, r_2;
cout << "Press return after each number.\n";
cout << "what is the value of a?\n";
cin >> a;
cout << "what is the value of b?\n";
cin >> b;
cout << "what is the value of c?\n";
cin >> c;

r_1=(-b+sqrt((b*b)-(4*(a)*(c))))/(2*a);
cout << "r_1(root1) is:\n";
cout << r_1;

r_2=(-b-sqrt((b*b)-(4*(a)*(c))))/(2*a);
cout<< "r_2(root2) is:\n";
cout<< r_2;

system ("pause");

return 0;
}
Last edited on
If you're using Visual Studios, just double click on the error messages and it should take you to the line where the error is.

And most of the time, if you get a gigantic error list, it's because you're making 1 or 2 mistakes, and that's causing a bunch of other mistakes to pop up.

The error messages are saying you're missing a ";" somewhere. Double click and you should know which line it is. If that ";" is missing, then the line after it is invalid, and so on, and so on, ....

And about error messages: They only start out weird. They used to really annoy me too.

Just skip to the end of the message and you can see what it is. For example, syntax error : missing ';' before ':' means exactly what it says.
The problem is often on a previous line than the one where the error is reported.
In this case there are too many semicolons. Here for example:
int main(); remove the semicolon.

Also, this close-brace open-brace in the middle of main()
1
2
}
{

That's pretty certain to mess things up. The first one will be the closing brace for the body of main(), and the second will be the start of -- well, nothing in particular. That leaves the remaining code orphaned, it isn't part of any function. So I would get rid of those.
Last edited on
Topic archived. No new replies allowed.