Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can I make a code for solving Quadratic Iquations ?

+3 votes
asked Jan 31, 2025 by Abdullah Shafi (340 points)

1 Answer

+1 vote
answered Feb 1, 2025 by abhiram rangavajhala (810 points)
make variables for a, b, and c in the equation. Then just do the arithmetic given in the quadratic equation.
commented Feb 1, 2025 by Giuseppe Carella (100 points)
like -b +- sqrt of square b -4ac all divided by 2a?
commented Feb 1, 2025 by Shaik Abdul Rehaman (140 points)
#include<stdio.h>
#include<math.h> //whenever if you want to perform higher level of mathematical operations  you should add math directive too//
float a,b,c,r1,r2;
printf("enter a,b,c ");
scanf("%f%f%f",&a.&b,&c);
r1=(-b+sqrt(b*b-4*a*c))/(2*a); //in this way we split formula, braces are mandatory
r2=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("the roots of quadratic equations are %f %f", r1,r2);
return 0;
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...