Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double square(double);
- double square2(double);
- int main()
- {
- // Variables
- ofstream outFile;
- double PI = 3.14;
- double side;
- double radius;
- double s_cube;
- double s_sphere;
- // Prompting user
- outFile.open("output.txt");
- cout << " Enter side of cube. " << endl;
- cin >> side;
- cout << " Now enter radius of the sphere. " << endl;
- cin >> radius;
- // Calling functions
- s_cube = square(side);
- s_sphere = square2(radius) * PI;
- // Printing message to file open
- outFile << " The surface of the cube with sides " << side << " is " << s_cube << endl;
- cout << " The surface of the cube with sides " << side << " is " << s_cube << endl;
- cout << endl;
- outFile << " The surface of a sphere of radius " << radius << " is " << s_sphere << endl;
- // Close file
- outFile.close();
- system("pasuse");
- return 0;
- }
- // Functions
- double square(double side)
- {
- double s_cube = 0;
- s_cube = 6.0 * side * side;
- return s_cube;
- }
- double square2(double radius)
- {
- double s_sphere = 0;
- s_sphere = 4.0 * radius * radius;
- return s_sphere;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement