Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Use the Pythagorean theorem to find find the length of the hypotenuse

#include <iostream>  #include <cmath>  using namespace std;     int main() {       double x, y, z;      x = 5;    y = 4;      z = sqrt(x*x + y*y);      cout << "Hypotenuse is " << z;      return 0;  } Hypotenuse is 6.40312"