Advertisement
keysle

Velocity vector thing

May 12th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. // my second program in C++
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main ()
  8. {
  9.     double X = 6.66;
  10.     double Y = 5.44;
  11.     double Z = 2.33;
  12.     double velocity;
  13.    
  14.     velocity = sqrt(pow(Z,2)+pow(Y,2)+pow(Z,2));  // actual air speed
  15.  
  16.  
  17.     cout << "X speed: " << X << endl;
  18.     cout << "Y speed: " << Y << endl;
  19.     cout << "Z speed: " << Z << endl;
  20.  
  21.     cout.precision(3); // for 2 decimal places.
  22.  
  23.     cout << "Velocity: " << velocity << endl;
  24.  
  25.     system ("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement