Whenever i try to run it, there's 3 erros but i don't know where, This is my first program and I'm new at this.
Write a C program that
Reads the coefficients (double a, b, c) of a quadratic equation a*x2..+..b*x..+..c..=..0
Computes the roots of that equation (if exist), and
Prints out an appropriate msg with roots (if any).
..
For example,
when a =0, we have a linear equation and we have only one root x=-c/b.
Compute d =....4*a*c - b2.
For d<0, we have two real roots,
For d=0, we have one root,
For d>0, we have no root
Code:
#include<stdio.h>
#include<math.h>
int main(void)
{
/*Declare variables*/
double a, b, c, d;
/*Request Information from user*/
printf("Enter Value for a:");
scanf("%lf", &a);
printf("Enter Value for b:");
scanf("%lf", &b);
printf("Enter Value for c:");
scanf("%lf", &c);
/*Perform Calculations*/
printf("Equation: %fx^2 + %fx + c = 0\n", a, b, c);
if (a == 0)
{
printf("we have one root\n");
}
else
{
d = b * b - 4 * a * c;
if (d < 0)
{
printf("we have two real roots\n");
}
else if (d == 0)
{
printf("we have one root\n");
}
else if (d > 0)
{
printf("we have no root\n");
/*Exit Program*/
return 0;
}