To elaborate Rick and Richard solution, try
#include <stdio.h>
#include <math.h>
int main()
{
printf("ax^2+bx+c\n\n");
int a, b, c;
printf("enter integer a\n");
scanf("%d", &a);
printf("enter integer b\n");
scanf("%d", &b);
printf("enter integer c\n");
scanf("%d", &c);
double d = b * b - 4 * a * c;
if ( b < 0)
{
}
else
{
d = sqrt(d);
double x1, x2;
x1 = (- b + d)/2/a;
x2 = (- b - d)/2/a;
printf("x1=%g, x2=%g\n", x1, x2);
}
return 0;
}
Please note:
- You have to include the
<math.h>
header (and possibly link with the math library) - You don't actually need the
pow
function, the sqrt
function is just enough - In order to divide something by
2a
, you must write either
something/2/a
or
something/(2*a)
(writing,as you did, something/2*a
is plain wrong).