Advertisement
kalin729

Quadratic Formula and A= x1+2*x2

May 14th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include<iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. double returnA(double a, double b, double c){
  7.  
  8.     double  x1, x2, A2;
  9.     double D = b*b - 4*a*c;
  10.  
  11. if(a==0){
  12.     cout<< "\"a\" ne moje da e 0!"<< endl;
  13. }else if(D<0){
  14.     cout << "Nyama reshenie!";
  15. }else{
  16. x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 *a);
  17.  
  18. x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
  19.  
  20. A2 = x1 + 2*x2;
  21.  
  22. cout << "A=" << A2;
  23.     }
  24.  
  25. }
  26.  
  27. int main(){
  28.  
  29. double a, b, c;
  30.  
  31. cout << "a= ";
  32. cin >> a;
  33. cout << "b= ";
  34. cin >> b;
  35. cout << "c= ";
  36. cin >> c;
  37.  
  38. returnA(a, b, c);
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement