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
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
is it possible to create your own header files?
What is the purpose of scanf() and printf() functions?
In C programming, what command or code can be used to determine if a number of odd or even?
how to create duplicate link list using C???
What is the size of enum in c?
What is null pointer constant?
How to write a code for reverse of string without using string functions?
Explain indirection?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
Can we assign integer value to char in c?
What are the header files used in c language?
Are c and c++ the same?
What do the functions atoi(), itoa() and gcvt() do?
Why c is called top down?