B
Bshealey786
Okay im doing my final project for my first computer science class(its
my major, so it will be my first of many), but anyway im a beginner so
im not to great with C++ yet. Anyway this is the error msg that im
getting: "Error executing cl.exe"
this is the code that I have, but I know whats causing it, ill just
show you the whole thing first though
//file: Quadratic
#include <iostream.h>
#include <math.h>
#include <string>
void main ()
{
char name [10];
char runagain;
double discriminant;
double root1;
double root2;
double a;
double b;
double c;
cout << "What is your name? " << endl;
cin.getline (name,10);
cout << "Hello " << name << " we are now ready to begin. Lets compute
the roots of your quadratic equation" << endl;
while (char runagain = "y")
{
cout << "A-----> ";
cin >> a;
cout << "B-----> ";
cin >> b;
cout << "C-----> ";
cin >> c;
cout << "The equation is " << a << " * x * x + "<< b << " * x + "<< c
<< endl;
if (a==0 && b==0)
{
cout << " Linear equation, root at " << - c / b << endl;
}
else
{
discriminant = b * b - 4 * a * c;
if (discriminant < 0);
cout << "imaganary roots" << endl;
}
if (discriminant == 0)
{
root1 = - b / 2 * a ;
root2 = root1;
cout << "Two equal real roots: ";
cout << "Root 1 = " << root1 << " and Root 2 " << root2;
}
else
{
root1 = ( - b + sqrt (discriminant) / (2 * a ) );
root2 = ( - b - sqrt (discriminant) / (2 * a ) );
cout << "Two distinct real roots: " << endl;
cout << "Root 1 = " << root1 << " and Root 2 = " << root2 << endl;
}
cout << "Would you like to run this program again, please enter y for
yes, and n for no" << endl;
cin >> runagain;
}
cout << "Have a good day";
}
Okay the program worked, but then I have to put a loop in there and
thats when I starting getting the error, so im sure its my loop
statement thats causing the problem, ive tinkered around with it and
still cant figure out how to fix it. Someone said I needed to add "do"
after my while loop line, but then I get the same error plus one that
says "syntax error: identifier 'cout'". Hopefully this is an easy fix
and someone will be able to help me out, thanks in advance!
my major, so it will be my first of many), but anyway im a beginner so
im not to great with C++ yet. Anyway this is the error msg that im
getting: "Error executing cl.exe"
this is the code that I have, but I know whats causing it, ill just
show you the whole thing first though
//file: Quadratic
#include <iostream.h>
#include <math.h>
#include <string>
void main ()
{
char name [10];
char runagain;
double discriminant;
double root1;
double root2;
double a;
double b;
double c;
cout << "What is your name? " << endl;
cin.getline (name,10);
cout << "Hello " << name << " we are now ready to begin. Lets compute
the roots of your quadratic equation" << endl;
while (char runagain = "y")
{
cout << "A-----> ";
cin >> a;
cout << "B-----> ";
cin >> b;
cout << "C-----> ";
cin >> c;
cout << "The equation is " << a << " * x * x + "<< b << " * x + "<< c
<< endl;
if (a==0 && b==0)
{
cout << " Linear equation, root at " << - c / b << endl;
}
else
{
discriminant = b * b - 4 * a * c;
if (discriminant < 0);
cout << "imaganary roots" << endl;
}
if (discriminant == 0)
{
root1 = - b / 2 * a ;
root2 = root1;
cout << "Two equal real roots: ";
cout << "Root 1 = " << root1 << " and Root 2 " << root2;
}
else
{
root1 = ( - b + sqrt (discriminant) / (2 * a ) );
root2 = ( - b - sqrt (discriminant) / (2 * a ) );
cout << "Two distinct real roots: " << endl;
cout << "Root 1 = " << root1 << " and Root 2 = " << root2 << endl;
}
cout << "Would you like to run this program again, please enter y for
yes, and n for no" << endl;
cin >> runagain;
}
cout << "Have a good day";
}
Okay the program worked, but then I have to put a loop in there and
thats when I starting getting the error, so im sure its my loop
statement thats causing the problem, ive tinkered around with it and
still cant figure out how to fix it. Someone said I needed to add "do"
after my while loop line, but then I get the same error plus one that
says "syntax error: identifier 'cout'". Hopefully this is an easy fix
and someone will be able to help me out, thanks in advance!