Hello all,
I hope I am not bombarding you with my problem but I need to know what was wrong with the code below:
Code:
/* program to calculate the root of a quadratic equation*/
#include <stdio.h>
#include <math.h>
main()
{
float a, b, c, d, r=0.0, x1, x2;
printf ("\nEnter value for a\n");
scanf ("%f", &a);
printf ("\nEnter value for b\n");
scanf ("%f", &b);
printf ("\nEnter value for c\n");
scanf ("%f", &c);
d=sqrt((b*b)-4*a*c);
if (d>r)
x1=(-b+d)/(2*a);
x2=(-b-d)/(2*a);
printf("\nThe real roots are %f, %f\n", x1, x2);
else if (d<r){
printf ("\nThere are no real root because the equation turns to infinity\n");
};
else
x1=(-b/2*a);
x2=(-b/2*a);
printf("\nThe real roots are %f, %f\n", x1, x2);
}
Below is the error:
c:\program files\miracle c\quadrati.c: line 18: Parse Error, expecting `'}''
'else if (d<r){ printf ("\nThere are no real root because the equation turns to infinity\n")'
aborting compile
Please help out.