/* ************************************************************************** * Program name : 038_Hypotenuse (Version 1.00) * * Author : Duck Wong * * Language : C / C++ * * Compiler : Boodshed Dec-C++ compiler Ver 3.95 * * Computer : PII350 * * O/S : Windows 98 * ************************************************************************** * Version 1.00 : 2000/06/04 - first version * ************************************************************************** * Description : (a) intut the length of 2 sides of a triangle * * (b) find the length of the hypotenuse * * (c) output results * ************************************************************************** */ #include #include #include float findhypotenuse(float side_A, float side_B) { return sqrt(side_A*side_A+side_B*side_B); } int main() { // part 1 : declaration float side_A, side_B, side_C; char YN; do { // part 2 : input cout << " Calculate the length of the hypotenuse (Version 1.0)\n\n"; cout << "\a\t" << "Enter the length of Side A : "; cin >> side_A; cout << "\a\t" << "Enter the length of Side B : "; cin >> side_B; cout << "\n"; // part 3 : calculate & output the result cout << "\a\t" << "The length of Side C is "; cout << findhypotenuse(side_A,side_B); // part 4 : try again cout << "\n\n\a Try again (Y/N) : "; cin >> YN; cout << "\n\n"; } while (YN == 'Y' || YN == 'y'); system("PAUSE"); return 0; }