//This program demonstrates the use of reference parameters //in computing the volume and surface area of a cylinder //It also shows how to pass a file variable to a function //No formatting has been done in this version of the program const double PI = 3.141592; //global constant #include #include using namespace std; void getCyl(float &, float &); void computeCylinder(float, float, float &, float &); void writeResults(float volume, float surfArea); void writeResultstoFile( ofstream &fout, float radius, float height, float volume, float surfArea); int main() { ofstream fout; fout.open("CYL.TXT"); float radius, height; //dimensions of the cylinder float radius2, height2; float volume, surfArea; float volume2, surfArea2; getCyl(radius, height); computeCylinder(radius, height, volume, surfArea); writeResults(volume, surfArea); writeResultstoFile(fout, radius, height, volume, surfArea); getCyl(radius2, height2); computeCylinder(radius2, height2, volume2, surfArea2); writeResults(volume2, surfArea2); writeResultstoFile(fout, radius2, height2, volume2, surfArea2); return 0; } /* getCyl() inputs the dimensions of a cylinder */ void getCyl( float & rad, float & ht) { cout << "Enter the radius of a cylinder "; cin >> rad; cout << "Enter the height of the cylinder "; cin >> ht; } /* computeCylinder() computes the volume and the surface area of a cylinder */ void computeCylinder(float rad, float ht, float &vol, float &surfArea) { vol = PI * rad * rad *ht; surfArea = 2*PI * rad * rad + 2*PI *rad* ht; //cout << rad << " " << ht << " " << vol << " " << surfArea <