aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk6/lab5/momentum.cpp
blob: ef7a7e730a710361120094bf0b8c30fe039949d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

double* momentum (double velocity[3], double mass);

int main() {
  double velocity[3];
  double mass;
  std::cout << "Please enter velocity (x y z) [m/s]: ";
  std::cin >> velocity[0] >> velocity[1] >> velocity [2];
  std::cout << "Please enter mass [kg]: ";
  std::cin >> mass;
  momentum(&velocity[3], mass);
}

double* momentum(double velocity[3], double mass) {
  double* vector;
  vector = new double[3];
  for (int i=0; i<2; i++) {
    vector[i]=velocity[i]*mass;
  }
  return vector;
}