In this q i m only getting one testcase wrong. But i am unable to figure out the mistake in the following code

#include
#include
using namespace std;
int main() {

int a,b,c;

cin>>a;
cin>>b;
cin>>c;
int D;

D=pow(b,2)-(4*a*c);
if(a>0){
int root1=(-b+sqrt(D))/(2*a), root2= (-b-sqrt(D))/(2*a);


	if(D==0){
	    cout<<"Real and Equal"<<endl;
		
		cout<<root1<<" "<<root2<<endl;
		cout<<root1<<" "<<root2;}
		
	if(D>0){
	cout<<"Real and Distinct";
	cout<<"\n";
	if(root1>root2){
	cout<<root2<<" "<<root1<<endl;}
	else{
		cout<<root1<<" "<<root2;
	}

	}
	else{
		cout<<"Imaginary";
	}
}

return 0;

}

link for the question-
https://online.codingblocks.com/app/player/246132/content/235743/4699/code-challenge

hi @sbhardwaj1be21_2a991b329433c059 corrected https://ide.codingblocks.com/s/666455

1 Like