1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
namespace Physics {
const double G = 9.81; // Acceleration due to gravity
double calculateFallingDistance(double time) {
return 0.5 * G * time * time;
}
}
using namespace Physics;
using std::cout;
using std::endl;
int main() {
double time = 3.0; // seconds
cout << "Distance fallen in " << time << " seconds: "
<< calculateFallingDistance(time) << " meters" << endl;
return 0;
}
Back to namespace