biquadratic equation source code


/ Published in: C++
Save to your folder(s)

A simple program solving a biquadratic equation.


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. void main()
  6. {
  7. float a, b, c, dis, x1, x2;
  8. cout << "Enter a: ";
  9. cin >> a;
  10. cout << "Enter b: ";
  11. cin >> b;
  12. cout << "Enter c: ";
  13. cin >> c;
  14. dis = b*b - 4*a*c;
  15. if ( dis>= 0 )
  16. {
  17. x1 = (b - sqrt (dis) ) / 2*a;
  18. x2 = (b + sqrt (dis) ) / 2*a;
  19. cout << "The result is" << x1 << " and " << x2 << endl;
  20. } else
  21. {
  22. cout << "Dis is less than 0\n";
  23. }
  24. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.