write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / shariful islam
#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
What is wrong in this statement?
What is pragma in c?
Tell us two differences between new () and malloc ()?
What is the difference between exit() and _exit() function in c?
What are the primitive data types in c?
Why is c not oop?
I need a sort of an approximate strcmp routine?
Define C in your own Language.
How can I insert or delete a line (or record) in the middle of a file?
What is extern keyword in c?
Where does the name "C" come from, anyway?
In c language can we compile a program without main() function?
How do I use void main?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
write a program to rearrange the array such way that all even elements should come first and next come odd