432,549 Members | 1,717 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,549 IT Pros & Developers. It's quick & easy.

# A quadratic equation in c

 P: 1 Hi...I 'am new in C and I want a program that solves a quadratic equation!! I try something by my self to write some code about that but I want you to help me writing a new one that will work!! Expand|Select|Wrap|Line Numbers   #include  #include  #include    int main(void)   {   float a,b,c,d,root1,root2;   printf("Welcome to the Quadratic Equation Solver\n"); printf("----------------------------------------\n"); printf("Please enter the 3 coefficients a, b, c : \n"); printf("Enter coefficient a: \n"); scanf("%f", &a); printf("Enter coefficient b: \n"); scanf("%f", &b); printf("Enter coefficient c: \n"); scanf("%f", &c); printf("Enter coefficient d: \n"); scanf("%f", &d);   if(a == 0 && b == 0) printf("Both a and b cannot be 0 in ax^2 + bx + c = 0 \n");   }else   d=-c/b; { printf("The solution of the linear equation is : \n");     }else{   d=b*b-4*a*c;   if(d>0)   root1=(-b+sqrt(d))/(2*a); root2=(-b-sqrt(d))/(2*a); { printf("The first root = \n"); printf("The second root = \n");   return 0; } }     I need it as soon as possible!!! Thankssss very much! Nov 29 '07 #1 