< previous page page_167 next page >

Page 167
0167-01.gif
Variables
NameDate TypeDescription
lengthOfafloatLength of one of the known sides
lengthOfbfloatLength of the other known side
sumOfSquaresfloatSum of the squares of the two known sides
hypotenusefloatLength of the hypotenuse

Here is the complete program. Notice how we've used the module names as comments to help distinguish the modules from one another in our flat implementation.
//******************************************************************
// Triangle program
// This program finds the length of the hypotenuse of a right
// triangle, given the lengths of the other two sides
//******************************************************************
#include <iostream.h>
#include <iomanip.h>    // For setw() and setprecision()
#include <math.h>       // For sqrt()

int main()
{
    float lengthOfA;         // Length of one of the known sides
    float lengthOfB;         // Length of the other known side
    float sumOfSquares;      // Sum of the squares of the known sides
    float hypotenuse;        // Length of the hypotenuse

 
< previous page page_167 next page >