Abel9210

Volume and Surface Area of Cylinder program

Mar 15th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //This program attempts to calculate the volume and surface area of a cylinder when given height and radius.
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. const double pi = 3.14;
  11. double height;
  12. double radius;
  13. double Volume;
  14. double Surface_Area;
  15.  
  16. cout << fixed << showpoint << setprecision(2);
  17.  
  18. cout << "Enter the height and radius: ";
  19. cin >> height >> radius;
  20. cout << endl;
  21.  
  22. cout << "The height is " << height
  23. << ", and the radius is " << radius
  24. << "." << endl;
  25. Volume = pi * radius * radius * height;
  26. Surface_Area = (2 * pi * radius * height) + (2 * pi * radius * radius);
  27. cout << "The volume and surface area of the cylinder are " << Volume
  28. << " and " << Surface_Area
  29. << ", respectively." << endl;
  30.  
  31. system("pause");
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment