SHARE
TWEET

Untitled

a guest Oct 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float getSideA();
  2. float getSideB();
  3. float calcSideC(float sideA, float sideB);
  4. float displaySideC(float sideC);
  5. int main()
  6. {
  7.     float sideA;
  8.     float sideB;
  9.     float sideC;
  10.  
  11.     sideA = getSideA();
  12.     sideB = getSideB();
  13.     sideC = calcSideC(sideA, sideB);
  14.     displaySideC(sideC);
  15.  
  16.     system("pause");
  17.     return 0;
  18. }
  19. float getSideA()
  20. {
  21.     float sideA;
  22.  
  23.     cout << "Enter two sides of a right triangle." << endl << endl
  24.         << "Side A:\n" << "Please enter the dimension: ";
  25.     cin >> sideA;
  26.  
  27.     return sideA;
  28. }
  29. float getSideB()
  30. {
  31.     float sideB;
  32.  
  33.     cout << "\nSide B:\n" << "Please enter the dimension: ";
  34.     cin >> sideB;
  35.  
  36.     return sideB;
  37. }
  38. float calcSideC(float sideA, float sideB)
  39. {
  40.     float sideC;
  41.    
  42.     sideC = pow(sideA, 2) + pow(sideB, 2);
  43.    
  44.     return sideC;
  45. }
  46. float displaySideC(float sideC)
  47. {
  48.     cout << "\nThe dimension of Side C is: " << sqrt(sideC) << endl << endl;
  49.    
  50.     return 0;
  51. }
  52. /*OUTPUT
  53. Enter two sides of a right triangle.
  54.  
  55. Side A:
  56. Please enter the dimension: 3
  57.  
  58. Side B:
  59. Please enter the dimension: 4
  60.  
  61. The dimension of Side C is: 5
  62.  
  63. Press any key to continue . . .
  64. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top