Trying to write a program to compute the hypotenuse of a right triangle.

I feel I am very close but I cannot see my error. As of now, the program compiles without error, runs without erroring out, but it does not display the answer. It just takes the input and then quickly closes.

Here is what I have so far:

#include <iostream> #include <cmath> using namespace std; int main () { float A, B; float side1; float side2; float side3; // Program Starts cout << "Hypotenuse of a right triangle\n"; // Program title cout << "\nA^2+B^2=C^2 (Principle of the Pythagorean Theorem)\n"; //Mathmatical formula cout << "\nEnter Length of Side A\n\n"; cout << "A = "; cin >> A; cout << "\nEnter Length of Side B\n\n"; cout << "B = "; cin >> B; { side1=pow(A,2); side2=pow(B,2); side3 = sqrt((side1+side2)); //Compute hypotenuse of triangle cout << "\n\n Side 1 is " <<side1; cout << "\n Side 2 is " <<side2; cout << "\n The Hypotenuse is " <<side3; } }

Any suggestions or comments on where I am going wrong?

Thanks in advance!

MOD EDIT: When posting code...USE CODE TAGS!!!

This post has been edited by **JackOfAllTrades**: 09 September 2010 - 12:57 PM

Reason for edit:: Added code tags.