Skip to main content
Search
Search This Blog
Livecodo
Pages
Home
Courses
Blog
About us
More…
Share
Get link
Facebook
X
Pinterest
Email
Other Apps
March 28, 2024
Write a C program to find the roots of a quadratic equation.
# include
# include
int main () { float a,b,c,r1,r2,d; printf ("Enter the values of a b c: "); scanf (" %f %f %f", &a, &b, &c); d= b*b - 4*a*c; if (d>0) { r1 = -b+sqrt (d) / (2*a); r2 = -b-sqrt (d) / (2*a); printf ("The real roots = %f %f", r1, r2); } else if (d==0) { r1 = -b/(2*a); r2 = -b/(2*a); printf ("Roots are equal =%f %f", r1, r2); } else printf("Roots are imaginary"); return 0; }
Popular Posts
March 26, 2024
Dynamic Memory allocation in C
May 18, 2024
Searching and sorting Algorithm in C