#include #include #include //all the include statements are like toolboxes of commands and capabilities // without them, you couldn't do math or anything requiring input or output! //note:name of file usually must have proper extension, depending on //compiler, e.g. .cpp for microsoft C++. int main() { FILE *fp; fp=fopen("fudge","w"); double dt,v,t; double z; double vo; // notice that all variables are declared double precision at the start. // File and fp statements open a file named fudge for data storage // Next initialize z. z=0.; cout<<"enter vo"<>vo; cout<<"enter dt"<>dt; t=t-dt; do { t=t+dt; z=z+v*dt; v=vo-9.8*dt; vo=v; fp=fopen("fudge","a"); fprintf(fp,"%18.6f%18.6f\n",t,z); fclose(fp); //results are in fudge and also outputted to the screen. cout <<"t="<