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 kind of structure is a house?
What is the value of uninitialized variable in c?
What is the purpose of type declarations?
What does %p mean?
What are different storage class specifiers in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
How can you increase the size of a dynamically allocated array?
What is indirection in c?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
What is the acronym for ansi?
Explain what are bus errors, memory faults, and core dumps?
What is difference between union All statement and Union?
What is volatile variable how do you declare it?
What is int main () in c?
Explain what are multidimensional arrays?