|
|
|
| Variables | | | | Name | Date Type | Description | | lengthOfa | float | Length of one of the known sides | | lengthOfb | float | Length of the other known side | | sumOfSquares | float | Sum of the squares of the two known sides | | hypotenuse | float | Length 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
|
|
|
|
|
|