Write a C program to find the roots of a quadratic equation | Roots of quadratic equation program in C

Spread the love
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. void main()
  5. {
  6. float a,b,c,root1,root2;
  7. clrscr();
  8. printf(n Enter values of a,b,c for finding roots of a quadratic eq:n);
  9. scanf(“%f%f%f”,&a,&b,&c);
  10. /*checking condition*/
  11. if(b*b>4*a*c)
  12. {
  13. root1=(-b+sqrt(b*b4*a*c))/2*a;
  14. root2=(-bsqrt(b*b4*a*c))/2*a;
  15. printf(n*****ROOTS ARE*****n);
  16. printf(n root1=%fn root2=%f”,root1,root2);
  17. }
  18. else
  19. printf(n Imaginary Roots.”);
  20. getch();
  21. }

Also Read :

  1. Modulo operator in C explained with Examples.
  2. In depth examples on Arithmetic operators.
  3. Arithmetic operators in C language.
  4. Compilation Stages in C language.
  5. Identifiers in C language and Rules for naming Identifiers.
  6. Structure of C Language.

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply