Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. float getSide();
  2. float calcSideC(float sideA, float sideB);
  3. float displaySideC(float sideC);
  4. int main()
  5. {
  6. float sideA;
  7. float sideB;
  8. float sideC;
  9.  
  10. cout << "Side A: \n";
  11. sideA = getSide();
  12. cout << "Side B: \n";
  13. sideB = getSide();
  14. sideC = calcSideC(sideA, sideB);
  15. displaySideC(sideC);
  16.  
  17. system("pause");
  18. return 0;
  19. }
  20. float getSide()
  21. {
  22. float sideInput;
  23.  
  24. cout << "Enter a side of a right triangle." << endl;
  25. cin >> sideInput;
  26.  
  27. return sideInput;
  28. }
  29. float calcSideC(float sideA, float sideB)
  30. {
  31. float sideC;
  32.  
  33. sideC = pow(sideA, 2) + pow(sideB, 2);
  34.  
  35. return sideC;
  36. }
  37. float displaySideC(float sideC)
  38. {
  39. cout << "\nThe dimension of Side C is: " << sqrt(sideC) << endl << endl;
  40.  
  41. return 0;
  42. }
  43. /*OUTPUT
  44. Side A:
  45. Enter a side of a right triangle.
  46. 3
  47. Side B:
  48. Enter a side of a right triangle.
  49. 4
  50.  
  51. The dimension of Side C is: 5
  52. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement