/* testfunc12.cpp CIS 150 6/9/2005 David Klick Passing arguments by reference. */ #include using std::cout; using std::cin; void getDimensions(double &height, double &width); int main(void) { double h, w; // height and width cout << "Rectangle area calculator\n"; getDimensions(h, w); cout << "The area is " << (h*w) << '\n'; return 0; } /* Gets height and width from user. */ void getDimensions(double &height, double &width) { // get height do { cout << "Enter height: "; cin >> height; if (height < 0.0) cout << "Error: height must be positive\n"; } while (height < 0.0); // get width do { cout << "Enter width: "; cin >> width; if (width < 0.0) cout << "Error: width must be positive\n"; } while (width < 0.0); }