Easy Programming

Practicing with the Pythagorean Theorem in C++:

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.

Click here to go back

//Programmer:	Nazmus
//Program:		Pythagorean Theorem
//Website:		EasyProgramming.net

#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;

	system("pause");

}