Posted By

dr3amerr on 10/25/10


Tagged

code equation source biquadratic


Versions (?)

biquadratic equation source code


 / Published in: C++
 

A simple program solving a biquadratic equation.

  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  

You need to login to post a comment.