I am supposed to write a program to give the maximum/minimum of a parabola...using user-input values of a,b and c and values of x from -20 to 20 at increments of 0.01.
the output is only supposed to be the value for y and x where y is max/min depending on the parabola....
i wrote the program (below) but its not working prprly....can sumboldy plz plz help me out??
Code:
#include <stdio.h>
int
main (void)
{
double a,b,c,x,y;
printf ("Enter values for a, b and c: ");
scanf ("%lf %lf %lf",&a,&b,&c);
for (x = -20.0;x<=20.0;x = x + 0.01)
{
if (a>0 && x == -(b/(4*a)))
{
y = a*(x*x) + b*x + c;
printf ("equation max/min of y value of x\n");
printf ("------------------- -------------- ----------\n");
printf ("y = %lfx*x - %lf - %lf %4.2f (min) %4.2f \n");
printf ("------------------- -------------- ----------\n");
}
else if (a<0 && x == -(b/(4*a)))
{
y = a*(x*x) + b*x + c;
printf ("equation max/min of y value of x\n");
printf ("------------------- -------------- ----------\n");
printf ("y = %lfx*x - %lf - %lf %4.2f (max) %4.2f \n");
printf ("------------------- -------------- ----------\n");
}
}
printf ("Report presented by ");
return (0);
}