Free-falling distance calculator in C++