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!!
I need it as soon as possible!!!
Thankssss very much!
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!!
Code:
#include <stdio.h> #include <stdlib.h> #include <math.h> 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; } }
Thankssss very much!
Comment