Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int pythag(double a, double b);
  6. int pythag2(double b, double c);
  7. int pythag3(double c, double a);
  8.  
  9.  
  10. int main()
  11. {
  12.     double a;
  13.     double b;
  14.    
  15.     cout << "Pythagorean theorem, Enter sides A and B and I will solve for C" << endl;
  16.     cin >> a >> b;
  17.  
  18.     cout << "Side C is equal to " << pythag(a, b) << endl;
  19.  
  20.     cout << "Now input for Side A" << endl;
  21.     cin >> a >> b;
  22.     cout << "Side A is equal to " << pythag2(b, a) << endl;
  23.  
  24.  
  25.     cout << "Now input for Side B" << endl;
  26.     cin >> a >> b;
  27.     cout << "Side B is equal to " << pythag3(b, a) << endl;
  28.  
  29.  
  30.     return 0;
  31. }
  32.  
  33. int pythag(double a, double b)
  34. {
  35.     double side1 = sqrt(pow(a, 2.0) + pow(b, 2.0));
  36.     return side1;
  37. }
  38.  
  39. int pythag2(double b, double c)
  40. {
  41.     double side2 = sqrt(pow(c, 2.0) - pow(b, 2.0));
  42.         return side2;
  43. }
  44.  
  45. int pythag3(double c, double a)
  46. {
  47.     double side3 = sqrt(pow(c, 2.0) - pow(a, 2.0));
  48.     return side3;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement