Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

// velocity.cpp : Defines the entry point for the console application.

//// Program to calculate velocity of a falling object

#include "stdafx.h"
double m = 68.1, c = 12.5, g = 9.8;
int dt = 1;
double velCalc(int, double);
int main()
{
FILE * pfile;

int time = 0;
double u = 0;
double v[1000];
fopen_s(&pfile, "myfile.txt", "w");
v[0] = u;
do
{
fprintf(pfile, "\nVelocity at time %d s: %lf \n", time, u);
time += dt;
v[time] = velCalc(time, u);
u = v[time];
} while (time < 21);

return 0;
}

double velCalc(int time, double u )


{
double v;
v = u + (g - (c / m)*u)*(time);
return v;
}

You might also like