I need To write a program that solves the quadratic equation for any a b c chose
ID: 2993668 • Letter: I
Question
I need To write a program that solves the quadratic equation for any a b c chosed. I have a good shell, but the oputput is incorrect. Please help me resolve this! The code is as follows:
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c;
float x,y,d;
printf("Enter a b c of quadratic equation separated by spaces ");
scanf("%d %d %d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d<0)
printf("Real number root is not possible. ");
else
x=(-b+sqrt(d))/(2*a);
y=(-b-sqrt(d))/(2*a);
printf("Solution of quadratic equation are %f %f ",x,y);
return 0;
}
Explanation / Answer
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c;
float x,y,d;
printf("Enter a b c of quadratic equation separated by spaces ");
scanf("%d %d %d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d<0)
printf("Real number root is not possible. ");
else
{
x=(-b+sqrt(d))/(2*a);
y=(-b-sqrt(d))/(2*a);
printf("Solution of quadratic equation are %f %f ",x,y);
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.