// sum of volume and mass of spheres #include #include using namespace std; namespace sphere { double volume(double r) { const double pi = 3.1416; return 4./3. * pi * pow(r, 3.); } double mass(double r, double rho) { return rho * volume(r); } } const double r1=1., r2=3.; // radii of spheres const double rho=7.87; // density int main() { using namespace sphere; double volume_sum = volume(r1) + volume(r2); // sphere:: omitted cout << volume_sum << endl; // total volume double mass_sum = mass(r1, rho) + mass(r2, rho); cout << mass_sum << endl; // total mass }