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

Is it VB.NET support operator overloading?

3 Answers   Zylog,


100 computers ip how to calculate

0 Answers   IBM,


is it possible to get u.s visa with 55% in b-tech and 15 backlogs

0 Answers  


tell me the e book for data structure (basic)

0 Answers  


what are differences between composition and inheritance in c

0 Answers  






Q.1 Write a C language program to perform CCITT group 3 compression. If possible, scan some images and use your program to compress the images. What kind of compression did you achieve? Q2. How does a magneto-optical technology differ from WORM technology? Explain the differences in the manner in which you would use them for a multimedia system. Q3. What network considerations would you contemplate in designing an enterprise-wide multimedia system which supports fully distributed integrated messaging, sharing of corporate multimedia information databases, and custom business process applications? Q4. Explain the difference between the various types of multimedia object servers. How would you set up hierarchical storage for a large distributed organization? Q5. Explain the role of each type of server required in a multimedia system and the type of storage media that should be used for it. Q6. How do your decisions affect the design? Would different decisions on network technologies and object server technologies result in a different solution?

0 Answers  


what is trx?

0 Answers   Enercon,


what is the effect of low frequency(say 48Hz) on TUrbo- Generator set when running for a prolonged period?

0 Answers   Bhel,


Please help to write testcase for ECG machine

0 Answers  


Hi all, Pls find the bellow mentioned interview questions related to hp-unix. 1. Job Scheduling; mainly crontab, at, batch command 2. Backup stetegy; incremental, full system back up; diff between tar & ufsdump 3. diff between hard link & softlink 4. How to list only the directories inside a directory (Ans. ls -l|grep "^d") 5. RAID levels; pros & cons of diffrent levels; what is RAID 1+0 6. How to recover a system whose root password has lost? 7. What is a daemon? 8. How to put a job in background & bring it to foreground? 9. What is default permissions for others in a file? 10. Questions on shell initialization scripts? 11. Questions on restricted shell 12. What is diff betwn grep & find? 13. What is egrep? 14. Questions on shell programming 15. What is a pipe? 16. Questions on Solaris patch management like pkgadd etc Thnaks & Regards Biswanath Das Email ID:biswanath_das84@yahoo.com

0 Answers   TCS,


How do trains go around bends?

0 Answers  


hi this is padhu i just want to know about remote sensing scientist in ISRO, will there a written test or not if there are any model test papers plz post it.

1 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4452)
  • Electrical Engineering Interview Questions Electrical Engineering (16636)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • 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 (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)