Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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.



Write a C program to solve the quadratic equation ax^2+bx+c=0. A quadratic equation has two roots..

Answer / sharifulislam

#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

More Engineering AllOther Interview Questions

funtionalities of loadining and linking

0 Answers  


through which part of the woman, wil the food go to foetus?

1 Answers   IOCL,


my first question in huawei was ....1)Tell me about your self 2) oops concept 3)logic gates 4)ram and rom ,what is cache memory nd where it is located 5)diffrence between file system and data base 6) procedure of operating system 7)what is c# 8)high level language and machine language 9) and from mobile networkin !!!! hope thz will help you

0 Answers   Huawei,


Can you connect Active Directory to other 3rd-party Directory Services? Name a few options.

0 Answers  


MES NEW DELHI

1 Answers   MES,






objective type quistion

0 Answers  


What have you done to improve or develop your knowledge / professional qualifications in the last year?

0 Answers  


what is D- channel ?

1 Answers   ZTE,


I have Cleared Bank of India Clerical Examination.I just want to know how to prepare for interview and what are the parriculars that I have to submit......Pls someone help me with it

0 Answers  


how to send request to the direct server rather than proxy server

0 Answers  


how the aeroplane protected from the lightening?

0 Answers   HEG,


Research reveals that high fiber content food is effective in preventing heart disease. However consumers are unable to take advantage of this finding as fiber content is usually not listed on the Nutrition Information label on food packages. Therefore as a further precaution in preventing heart disease, the government must regulate food industries to include the fiber content on the Nutrition Information label on food packages. Which of the following weakens the argument above?

1 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5081)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4448)
  • Electrical Engineering Interview Questions Electrical Engineering (16620)
  • Electronics Communications Interview Questions Electronics Communications (3915)
  • Chemical Engineering Interview Questions Chemical Engineering (1093)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (214)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (258)
  • Instrumentation Interview Questions Instrumentation (2993)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (171)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (0)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)