Question: The following code is for calculation quadratic equation. after putting values of a,b and c it prints as ax^2 + bx + C
so I want to include if command that if any value of a and b is 1 then it will ignore the 1. so, if a is 1 then equation should be x^2 + b + C. if b is 1 equation should be ax^2 + x + c. Simple there should not be any 1 in the equation other than c.
can anyone please enter the if command in my code? i have highlighted where you may put it.
You don't want a or be to actually be absent, you just don't want them displayed when the equation is being printed. The equations are printed in lines 30 and 31, so that's where you need to make the check.
Each of these lines would become multiple lines something like:
1 2 3 4 5 6 7 8 9 10 11
if (a != 1.0)
{
cout << a;
}
cout << "(" << e << ")^2 +";
if (b != 1.0)
{
cout << b << ".";
}
cout << e << " + " << c;
Note: what you currently print out is incorrect. You do not want (Ax)^2, you want A(x^2). Also you forgot the '+' before c