Discussion About Revising Quadratic Equations

This is Discussion thread about Revising Quadratic Equations

Hey @discobot this is my code for ques: Revising Quadratic Roots and I’ve also included the case of sq(-d) in case of imaginary roots but still not getting all ACs.

Please help.

#include<cmath>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int ans1, ans2;

	ans1 =  (-b + sqrt(pow(b,2) - 4*a*c))/2*a;
	ans2 =  (-b - sqrt(pow(b,2) - 4*a*c))/2*a;

	if(ans1!=ans2){
		cout<<"Real and Distinct"<<endl<<min(ans1,ans2)<<" "<<max(ans1,ans2);
	}

	else if(ans1==ans2){
		cout<<"Real and Equal"<<endl<<ans1<<" "<<ans1;
	}

	else if((pow(b,2) - 4*a*c)<0){
		cout<<"Imaginary";
	}
	return 0;
}

Hi! To find out what I can do, say @discobot display help.

mport java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int pow,sqrt,r1,r2;
//r1=(-b+Math.sqrt(Math.pow(b,2)-4ac))/2a;
//r2=(-b-Math.sqrt(Math.pow(b,2)-4ac))/2a;
pow=(int)Math.pow(b,2);
sqrt=(int)Math.sqrt(pow-4
ac);
r1=((-b+sqrt)/2
a);
r2=((-b-sqrt)/2a);
if(r1!=r2){
System.out.println(“Real and Distinct”);
System.out.println(r2+" "+r1);
}
else if((pow - 4
a*c)<0){
System.out.println(“Imaginary”);
}
else if(r1==r2){
System.out.println(“Real and Equal”);
System.out.println(r2+" "+r1);
}
}
}

foll is my code for quad eq problem @discobot
int a,b,c;
-100<= a,b,c<=100;
std::cin>>a;
std::cin>>b;
std::cin>>c;
int a1=(-b+(b^2-4ac)^(1/2))/2a;
int a2=(-b-(b^2-4ac)^(1/2))/2a;

if (a1!=a2 ){
	std::cout<<a1;
	std::cout<<a2;
	std::cout<<"Real and distinct";
}
if (a1==a2){
	std::cout<<a1;
	std::cout<<a2;
	std::cout<<"Real and Equal";
}
if ( (b^2-4*a*c)^(1/2)<0){
	std::cout<<"Imaginary";
}
std::cout<<std::endl;
return 0;

}

after compiling, it shows numeric literal operator error. "a’’
pls help