a simple algorithm and questions

As a test of my programming ability, I tried to write a

little program that inputs the diagonal of a monitor and

calculates the viewable area. It then optionally inputs

the diagonal of another monitor, calculates the viewable

area, and compares the two areas. (I got this idea when I

upgraded from a 15-inch to a 17-inch).

My algorithm is based on the Pythagorean Theorem and the

fact that monitors seem to have a 3:4 height-to-width

ratio. After a cin statement to get the float variable

inputDiag, which is the monitor's diagonal, it goes like

this:

diagSquared = inputDiag * inputDiag;

heightSquared = (diagSquared / 25) * 9;

widthSquared = diagSquared - heightSquared;

height = sqrt (heightSquared);

width = sqrt (widthSquared);

area = height * width;

return area;

My questions are as follows:

1. Is there a way to improve this algorithm?

2. If the values 25 and 9 above were changed to variables,

would the algorithm, as a function, be a candidate for

coversion to a header file I could later #include in any

programs that might need it, just to save me having to

type it in all over again?

Thanks for all replies.

Miki

ustuzou@sympatico.ca