Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- int main () {
- using namespace std;
- double cathetus_1, cathetus_2;
- cout << "Inserire cateto 1 e cateto 2: ";
- cin >> cathetus_1 >> cathetus_2;
- double hypotenuse;
- // Method 1
- // Applying the Pythagorean theorem
- hypotenuse = sqrt (
- ( cathetus_1 * cathetus_1 )
- + ( cathetus_2 * cathetus_2 ) );
- // Method 2
- // Applying the Pythagorean theorem
- hypotenuse = sqrt (
- pow ( cathetus_1, 2 )
- + pow ( cathetus_2, 2 ) );
- // Method 3
- // Applying the Pythagorean theorem
- hypotenuse = hypot ( cathetus_1, cathetus_2 );
- cout << hypotenuse << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment