#include "stdstuff.h" double square (double x) { return x * x; } double hypotenuse (double s1, double s2) { return sqrt (square(s1) + square(s2)); } double roofArea (double length, double width, double height) { double l_side_area, w_side_area; // work out area of triangle having base of length 'length' l_side_area = (length * hypotenuse(height, width / 2)) / 2; // work out area of triangle having base of length 'width' w_side_area = (width * hypotenuse(height, length / 2)) / 2; // return total area of the roof return (2 * l_side_area) + (2 * w_side_area); } int main () { double length, width, height; // prompt user for and read the input quantities cout << "Please enter length, width and height of roof: "; cin >> length >> width >> height; // output the result cout << "The total area of the roof is " << roofArea (length, width, height) << endl; pause(); return 0; }