"Revising Quadratic Eqautions"

I am stuck in this exercise !! I am pretty sure logically the code is correct but somehow output is not matching because of upper and lower case confusion or float to int conversion

Kindly help

#include #include using namespace std; int main() { int a,b,c; float root1 , root2, d ; cin >> a >> b >> c; d = bb - 4ac; if (d == 0){ cout<<“Real and Equal”<<endl; root1 = (-b)/(2a); cout<<(int)root1<<endl; } else if (d > 0){ cout<<“Real and Distinct”<<endl; root1 = ( (-b)+sqrt(d) )/(2a); root2 = ( (-b)-sqrt(d) )/(2a); cout<<(int)root1<<(int)root2<<endl; } else if (d < 0){ cout<<“Imaginary”<<endl; } return 0; }

@codersoumya If roots are real and distinct then you have to print the roots in increasing order. So make the necessary changes and then check if it passes all the test cases.
Consider Sample input:
1 -11 28

Expected Output:
Real and Distinct
4 7

In case your doubt is not resolved then please save you code on ide.codingblocks.com and then share its link.

Hope this helps :slightly_smiling_face:

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.