Advertisement
stefan1919

ClassWork

Feb 8th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void QuadraticEquation(int a, int b, int c, double &firstRoot, double &secondRoot){
  8.  
  9.     string equation = to_string(a) + "x^2 + " + to_string(b) + "x + " + to_string(c);
  10.     double discr = pow(b, 2) - 4 * a * c;
  11.  
  12.     if (discr >= 0)
  13.     {
  14.         firstRoot = (-b + sqrt(discr)) / double(2 * a);
  15.         secondRoot = (-b - sqrt(discr)) / double(2 * a);
  16.     }
  17.  
  18.     else
  19.     {
  20.         cout << "No real Root" << endl;
  21.     }
  22.  
  23. }
  24. void CallRoot(){
  25.     int a;
  26.     int b;
  27.     int c;
  28.     double first = 0;
  29.     double second = 0;
  30.  
  31.     cin >> a >> b >> c;
  32.  
  33.     QuadraticEquation(a, b, c, first, second);
  34.  
  35.     cout << first << endl;
  36.     cout << second << endl;
  37. }
  38. ///////////////////////////////////////////////
  39. ////////////////////////// Quadratic Equaation
  40. /////////////////////////////////////////////////
  41. int main(){
  42.  
  43.    
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement