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.
#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 |
hi,i just want to know the best institute to learn oracle in bangalore because i am doing my BE there?
write a c++ program to interchange two-integer number without using the third variable. use concept of constructor overloading.
describe what is const pointer and why do we need it?
What are your short and long term goals?
hi, please send me "state bank of india", last 5 years question paper with answers to my mail id.
Is Diesel staorage tank ( 800 litres) cleaning procedure is available with any body
What is the distance between earthing pit and equipment?
difference between tcp ip and open system interconnection
java support which type of polymorphism??runtym or compile tym or both??
what is far pointer?
how does data cleansing framework works?
what is the differences between DTD's and XML schema?
Civil Engineering (5086)
Mechanical Engineering (4456)
Electrical Engineering (16639)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)