guys its not working for me

im suppose to do this:

Write a program that reads 3 integer values representing the integer coefficients of a quadratic polynomial. The first
number represents the coefficient of X2 and must not be zero, the second number represents the coefficient of X, and
the third number represents the constant coefficient.
The purpose of the program is to compute the roots of the square polynomial.
If the polynomial has real roots it computes the two roots, otherwise it writes a message indicating that the polynomial
has no real roots.

The teacher is so confusing i dont what to do so, this is what i have

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

bool hasRealRoots ( int unita, int unitb, int unitc ) {
bool results;
if( (b * b) - 4 * a * c >= 0 ) {
result = true;
}
else {
result = false;
}

return result;
}

(if result == true)
a(x * x) + b * x + c
int(x * x) != 0
int a
int b
int c
int x
// compute roots
roots = ((- b * b) +/- sqrt( (b * b) - 4 * a * c )) / 2.0
display roots;

(if result == false)
display no roots;

int main(){

int a
int b
int c

system("Pause");
return 0;
}
its not compiling or working
Oh, boy.
This is all completely wrong. Even the quadratic formula is wrong.
Read this http://www.cplusplus.com/doc/tutorial/ and try to do your best. Not really much else I can say.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Um... This:
// bool hasRealRoots ( int unita, int unitb, int unitc ) {
bool hasRealRoots(int a, int b, int c) { //Why are the roots type int and not double?
   bool results;
   if( (b * b) - 4 * a * c >= 0 ) {
      result = true;
   }
   else {
      result = false;
   }

   return result;
}

//could be this:
bool hasRealRoots(int a, int b, int c) {
   return b * b - 4 * a * c >= 0;
}
Topic archived. No new replies allowed.