Thanks to all you guys... I am sorry but I should have done this to begin with. My ignorance of C++ (coughIcoughHATEcoughJAVAcough) is showing. Here is the whole program:
// gTrajectory.c: calculate the path of a mass, m,
// near the surface of the Earth
//
// DATE: 05/26/08
// TIME: 11:07 AM
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std; // C++ adopts space in memory
#define pi 3.14159 // standard constant
#define dt 0.00001 // time interval 1/100,000 of a second
double x[1001] = { 0.0 }; // declaring the path array
x[0] = 0.0e+9; // Initial Condition for x(0)
x[1] = 1.0e-5; // Initial Condition for x(1)
double m = 1.0; // mass of the moving object
double F = 9.8/m; // force of gravity
// cout << "\n t \t x(t) \n"; // the output header
int main()
{
ofstream gTraj; // create a file for output
gTraj.open ("gTrajectory.txt"); // open a file for output
gTraj << "\nt\tx(t)\n"; // the output header in the file
for (int i = 0 ; i <= 999 ; i++ ) // 1000 elements in x(t)
{
x[i+2] = -x[i] + 2*x[i+1] + (F/m)*dt*dt;
cout << i*dt << "\t" << x[i] << "\n"; // the output
gTraj << i*dt << "\t" << x[i] << "\n"; // the output
}
cout << "1000" << x[1001]; // the last one
gTraj.close();
return 0; // exit the program
}
PS: I just realized that maybe I should mention that I am using the free DJGPP compiler, which I installed. Also, thanks for the suggestion Duoas.
Thanks in advance!
-LD
____________________________
my faith:
http://www.angelfire.com/ny5/jbc33/