This program calculates the volume and the surface area of a cube in separate functions.
#include <iostream>
using namespace std;
double Volume (double a) {
double volume;
volume = a * a * a;
return volume;
}
double Surface (double a) {
double surface;
surface = 6 * a * a;
return surface;
}
int main () {
double edgeLength;
cout << "Please enter the edge length: " << endl;
cin >> edgeLength;
cout << "Volume: " << Volume(edgeLength) << endl;
cout << "Surface: " << Surface(edgeLength) << endl;
return 0;
}
Please enter the edge length:
5
Volume: 125
Surface: 150