daily pastebin goal
9%
SHARE
TWEET

Untitled

bbg6 Mar 21st, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using namespace std;
  2. // Prototypes
  3. double square(double side);
  4. double square2(double radius);
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. int main()
  12. {
  13.     // Variables
  14.     ofstream outFile;
  15.     double PI = 3.14;
  16.     double side;
  17.     double radius;
  18.     double s_cube;
  19.     double s_sphere;
  20.    
  21.     // Prompting user
  22.     outFile.open("output.txt");
  23.     cout << " Enter side of cube. " << endl;
  24.     cin >> side;
  25.     cout << " Now enter radius of the sphere. " << endl;
  26.     cin >> radius;
  27.     // Calling functions
  28.     s_cube = 6.0 * square(side);
  29.     s_sphere = 4.0 * square2(radius) * PI;
  30.     // Printing message to file open
  31.     outFile << " The surface of the cube with sides " << side << " is " << s_cube << endl;
  32.     cout << " The surface of the cube with sides " << side << " is " << s_cube << endl;
  33.     cout << endl;
  34.     outFile << " The surface of a sphere of radius " << radius << " is " << s_sphere << endl;
  35.     cout << " The surface of a sphere of radius " << radius << " is " << s_sphere << endl;
  36.     // Close file
  37.     outFile.close();
  38.  
  39.     system("pause");
  40.     return 0;
  41.  
  42. }
  43. // Functions
  44.  
  45. double square(double side)
  46. {
  47.     return side * side;
  48. }
  49. double square2(double radius)
  50. {
  51.     return radius * radius;
  52. }
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