plz find the error and do mention in code
Doubt in question of quadratic
your logic is correct, but you have not printed things correctly.
the final code is:
#include<bits/stdc++.h>
using namespace std;
// Prints roots of quadratic equation ax*2 + bx + x
void findRoots(int a, int b, int c)
{
// If a is 0, then equation is not quadratic, but
// linear
if(-100<=a && -100<=b && -100<=c)
{
if (a == 0)
{
cout << "Invalid";
return;
}
int d = b*b - 4*a*c;
double sqrt_val = sqrt(abs(d));
if (d > 0)
{
cout << "Real and Distinct"<<endl;
cout << (double)(-b - sqrt_val)/(2*a) << " "
<< (double)(-b + sqrt_val)/(2*a);
}
else if (d == 0)
{
cout << "Real and Equal"<<endl;
double d = -(double)b / (2*a);
cout << d<<" "<<d;
}
else // d < 0
{
cout<<"Imaginary"<<endl;
}
}
}
// Driver code
int main()
{
int a,b,c;
cin>>a>>b>>c;
findRoots(a, b, c);
return 0;
}
thansk
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.