This is Discussion thread about Revising Quadratic Equations
Discussion About Revising Quadratic Equations
import java.lang.Math;
import java.util.;
public class Main {
public static void main(String args[]) {
try{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int u=(bb)-(4ac);
if(u>0){
System.out.println(“Real and Distinct”);
double q=Math.sqrt(u);
int g=(int)q;
int s=(-b+g)/(2a);
int h=(-b-g)/(2a);
System.out.print(s+" "+h);
}
else if(u==0){
System.out.println(“Real and Equal”);
int s=-b/(2*a);
System.out.print(s+" "+s);}
else{}
}
catch(Exception e){System.out.print(e);}}}
Check plz what is problem with my code
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,D=0,x=0,y=0;
scanf("%d %d %d",&a,&b,&c);
D=D+(bb)-(4ac);
if(D>=0)
{
if(D>0)
{
x=x+(((-1b)-sqrt(D))/(2a));
y=y+(((-1b)+sqrt(D))/(2a));
printf(“Real and Distict\n”);
printf("%d %d",x,y);
}
else
{
x=x+((-1b)/(2*a));
printf(“Real and Equal\n”);
printf("%d %d",x,x);
}
}
else
{
printf(“Imaginary”);
}
return 0;
}[quote=“discobot, post:1, topic:20681, full:true”]
This is Discussion thread about Revising Quadratic Equations
[/quote]
Can anybody tell me what is wrong in this code . It is working perfectly in manual testing but when submitted showed wrong for last test case . I even unlocked test case and checked it manualy it is working properly .
it wants us to print roots in increasing order , just print h before s where u>0