English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

The formula for updating the y-position is

y = y + vy * DELTA_T ;



where vy is the vertical velocity, and we assume that at time zero y is 0. The vertical velocity is updated by



vy = vy - g * DELTA_T


(g = 9.8)


now can u write me a c program that update values of vy and y as shown in equations above. we have to use for or while loops but i m confused.

2006-10-28 18:58:41 · 1 answers · asked by skyrider 2 in Computers & Internet Programming & Design

1 answers

double y = 0; // time zero y is 0
double vy = somestartvalue;
double g = 9.8;
int t = 0;
int endTime = someStopTime;

for ( t = 0; t < endTime; t++ )
{
printf( "Time: %d - Y: %f VY: %f\n", t, y, d );
y = y + vy * (double)t;
vy = vy - g * (double)t;
}

2006-10-29 05:04:20 · answer #1 · answered by Daniel H 5 · 0 0

fedest.com, questions and answers