I am a newbie here so please be kind. I am writing a program that will tell the user the vertex of a parabola. The formula for a parabola is y=ax^2+bx+c. To find the vertex of the parabola you use the formula -b/2a. So here is my problem, when the user enters 3 coefficients (a,b,c) such as 2 2 2 and you plug a and b into the formula you get zero but what I'm suppose to get is -1/2 or -.5. For example, plug in the numbers -(2)/2*2 the program spits out zero. The rule is 1 divided 2 is zero but when you use a calculator of course the answer is .5. How can I get around this. Please help, this is due tomorrow night.

2. Try using floats instead of integers.

3. I tried using floats but didn't work. Here is a small part of the program. Hope you can help.

#include<stdio.h>
#include<math.h>

// Main

void main(void)
{
int a, b, c;
double x;
double y;
double y_intercept;
//double x;
//double y;
char ans;

puts("This project by James Volkman, analyzes");
puts("Equations of the form y=ax^2+bx+c.");
puts("The user will be asked to enter the coefficients a,b, and c.");
printf("Would you like to continue? ");
scanf(" %c", &ans);

while (ans == 'y' || ans == 'Y')
{
printf("\nEnter the coefficients a,b, and c of y=ax^2+bx+c: ");
scanf("%i%i%i", &a, &b, &c);

if (a > 0)
{
printf("The equation you entered is y=%ix^2+%ix+%i\n", a, b, c);
printf("It represents a parabola opening upward\n");
Here is the problem> x = (-b) / (2*a);
y = a*(x*x) + b*x +c;
printf("Vertex: (%g,%g)\n", x, y);
y_intercept = c;
printf("Y intercept (0,%g)\n", y_intercept);
printf("Would you like to continue? ");
}

else if (a < 0)
{
printf("The equation you entered is y=%ix^2+(%i)x+(%i)\n", a, b, c);
printf("It represents a parabola opening downward\n");
x = -(b)/(2*a);
y = a*(x*x) + b*x +c;
printf("Vertex: (%g,%g)\n", x, y);
y_intercept = c;
printf("Y intercept (0,%g)\n", y_intercept);
printf("Would you like to continue? ");
}

else
{
printf("The equation you entered is y=%ix^2+%ix+%i\n", a, b, c);
printf("It represents a line\n");
printf("Would you like to continue? ");

}

scanf(" %c", &ans);
}

return;
}

4. > void main(void)
should be int main(void)
add return 0; to the end of main

> scanf("%i%i%i", &a, &b, &c);
To get input with doubles use %g or %f (float).

- Sean

5. You are trying to mix data types. Try casting
Hint: x = (-(double)b) / (2.0 * (double)a);