Advertisement
Felanpro

hypot()

Jun 27th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. /* Swedish Explanation! */
  2.  
  3. #include <iostream>
  4. #include <stdlib.h>
  5. #include <cmath> //Acquire hypot() function/method.
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     /*Räkna ut längden av hypotenusan på en rätvinklig triangel.*/
  12.  
  13.     float x = 6;
  14.     float y = 8;
  15.  
  16.  
  17.     cout << hypot(x, y) << endl;
  18.  
  19.     /*
  20.  
  21.     Algoritm:
  22.  
  23.     x*x = 6*6 = 36
  24.     y*y = 8*8 = 64
  25.     36 + 64 = 100
  26.     Square Root of 100 = 10
  27.     Answer: 10
  28.  
  29.     */
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement