Originally Posted by
Salem
Well there were two mistakes, and you said you only fixed one of them.
Plus, simply describing your change rather than posting the actual code is not really informative.
I have now fixed both of those things and it is working. Thank you very much!!!
Code:
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include <math.h>
main()
{
double a,b,c,d,x,x1,x2;
printf("Enter the value for a: ");
a=GetReal();
printf("Enter the value for b: ");
b=GetReal();
printf("Enter the value for c: ");
c=GetReal();
if (a==0)
{
if (b==0)
{
printf("No solution");
}
else
{
x=(-c/b);
printf("The equation is not quadratic and the solution is:%.2f",x);
}
}
else
{
d=((b*b)-(4*a*c));
if (d<0)
{
printf("There is no real solution.");
}
else
{
if (d>0)
{
x1=(-b+(sqrt(d)))/(2*a);
x2=(-b-(sqrt(d)))/(2*a);
printf("There are 2 solutions. The first is %.2f and the second is %.2f",x1,x2);
}
else
{
if (d==0)
{
x1=(-b/(2*a));
printf("There is one solution which is %.2f",x1);
}
}
}
}
getchar();
}