Hey Guys,
Am a newbie in programming i have been assignment in school to write and print out the following below;
C program to solve Quadratic equation.
I have one below it is not running it keeps giving me errors.
#include<stdio.h>
void main()
{
float a,b,c,z,d,x,y;
printf("Enter the value of a,b,c");
scanf("%f %f %f",&a,&b,&c);
d=((b*b)-(4*a*c));
z=sqrt(d);
x=(-b+z)/(2*a);
y=(-b+z)/(2*a);
printf("The Quadratic equation is x=%f and y=%f",x,y);
1) sqrt() need a prototype header file, viz. <math.h>
2) Put a check for d<0, coz as Breadman said, d should not be negative, else your program will crash at run-time.
3) Both your roots are same. It should be: