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
Differentiate between new and malloc(), delete and free() ?
What are keywords in c with examples?
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
What is an identifier?
What is far pointer in c?
the question is that what you have been doing all these periods (one year gap)
FILE PROGRAMMING
Explain how do you list files in a directory?
What is difference between class and structure?
What is the advantage of an array over individual variables?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
C language questions for civil engineering
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
Are pointers integer?
What are the 3 types of structures?