Pythagorean Theorem

Published on: June 3, 2010

Learn to write a program that uses the Pythagorean theorem with ease. Most calculators can't do it but you can create a console application that does. It's simple, great practice for beginners, but still a bit more complex than the old yard to feet conversion tool. Uses Visual Studio 2008 C++ and estimated time to finish is just a few minutes.

Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.


//Programmer: Nazmus
//Program:  Pythagorean Theorem

#include <iostream>
#include <math.h>

using namespace std;

int main()


 float a, b, c;

 cout << "Please input the values of a and b: ";
 cin >> a >> b;

 c = a*a + b*b;
 c = sqrt(c);

 cout << "The hypotenuse is: " << c << '.' << endl;