No Idea what these compile errors are trying to tell me...

assignment2.cpp: In function `int main()':
assignment2.cpp:18: invalid suffix on integer constant
assignment2.cpp:18: warning: division by zero in `-b / 0'
assignment2.cpp:26: invalid suffix on integer constant
assignment2.cpp:26: warning: division by zero in `
(sqrt(double)(compute_discriminant) - b) / 0'
assignment2.cpp:27: invalid suffix on integer constant
assignment2.cpp:27: warning: division by zero in `((-b) -
sqrt(double)(compute_discriminant)) / 0'


Here's the code I have written so far:
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
#include "std_lib_facilities.h"

int main()
{
    cout << "Enter the coefficients (a,b,c) of your quadratic equation of form ax^2+bx+c" << endl;
    double a;
    double b;
    double c;
    int zero;
    zero=0;
    cin >> a >> b >> c;
    double compute_discriminant;
    compute_discriminant=(b*b)-(4*a*c);
    cout << "The Discriminant is" << compute_discriminant;
    if (compute_discriminant=zero){
        double double_real_root;
        double_real_root=(-b/(2a));
        cout << "x=" << double_real_root;
    }
    else if (compute_discriminant>zero){
        double two_real_roots;
        double Xone;
        double Xtwo;
        two_real_roots=(Xone,Xtwo);
        Xone=(-b+sqrt(compute_discriminant))/(2a);
        Xtwo=(-b-sqrt(compute_discriminant))/(2a);
        cout << "The two roots are" << two_real_roots;
    }
    return 0;
}
2a

You can't multiply numbers/variables like that. Use 2*a.
Thank You, all of this is blowing my mind but I'm slowly figuring it out.
1
2
3
4
5
if (compute_discriminant=zero){//this is wrong.
/*the = operator is assignment. the == operator is comparison.*/
two_real_roots=(Xone,Xtwo);//this is wrong.
/*The comma operator does not construct a list in C. 
It just discards the left argument and returns the right one.*/

Topic archived. No new replies allowed.