### Thread: Problem Help?

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Location
ミンダナオ、フィリピン
Posts
4
Rep Power
0

#### Problem Help?

Write a problem that will calculate the average velocity and acceleration from a series of measurements for the displacement and time of a falling stone. Find the velocity and acceleration as well.

So far I got this:

Code:
```#include <stdio.h>
#define N = 5

int main() {

int v[N], a[N];

int d[N] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6};

int t[N] = {0, 0.05, 0.2, 0.4, 0.8, 1.25, 1.8};

for (x=0;x<7;x++){
v[N] = d[x+1] - d[x] / t[x+1] - t[x];
}

printf ("velocities are %d", v[N]);

for (x=0;x<7;x++){
a[N] = v[x+1] - v[x] / t[x+1] - t[x];
}

printf ("acceleration are %d", a[N]);

system ("pause");

return 0;

}```
I know I'm still missing something but...yeah. A little help?
2. > #define N = 5
The form is
#define N 5

> int d[N] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6};
You have 7 elements, yet N is 5 ?

> for (x=0;x<7;x++){
Replace 7 with N, when you've decided on whether it's 5 or 7 through your code.

> v[N] = d[x+1] - d[x] / t[x+1] - t[x];
Maybe v[x] as well?
Also, watch out for the x+1 things. You're stepping off the ends of the arrays.

> printf ("velocities are %d", v[N]);
You'll need a for loop to do this, to print each v[x] individually.