Write a C program to solve the quadratic equation ax^2+bx+c=0.
A quadratic equation has two roots which are given by the following two formulas:
root1= -b+sqrt(b^2-4*a*c)/2*a
root1= -b-sqrt(b^2-4*a*c)/2*a
The program request the user for input a,b,c and the output will be root1 and root2.
Answer Posted / sharifulislam
#include<stdio.h>
#include<math.h>
int main(){
float a,b,c;
float d,root1,root2;
printf("Enter quadratic equation in the format ax^2+bx+c: ");
scanf("%fx^2%fx%f",&a,&b,&c);
d = b * b - 4 * a * c;
if(d < 0){
printf("Roots are complex number.
");
return 0;
}
root1 = ( -b + sqrt(d)) / (2* a);
root2 = ( -b - sqrt(d)) / (2* a);
printf("Roots of quadratic equation are: %.3f , %.3f",root1,root2);
return 0;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Please send me the ongc old question papers
what is the need for oobs
what is the differance between a technology and an engineering ?
convert 140 N.m/cm^2 to N.m/mm^2
CSS corp interview process and placement papers
if we give you the job AS A PETROLEUM ENGINEER WHAT WILL YOU DO(that is extraordinary) for our company
how configur net and vpn on cisco product
376,188,88,40,16,4,-2. Find wrong term in series
1.what a diffrenrs v-lan & (layer)l-3,l-2 bitween plz define defination of these? 2.how to configur ms outlook & lotus note (ibm)
need tcs questn papers from 2007 to 2009 plzzzmail to 9015.rama@gmail.com its urgent
what is the pri request of binary search
Reverse the link list without creating new list ?
as a student of b.tech 2nd yr which is the best place for me to do my summer training and plz also tell me the complete procedure for the entrance?
Can anyone send me iocl written test paper fro computer engineers
synchronous and asynchronous transmission