diff options
Diffstat (limited to 'accelarray.c')
| -rw-r--r-- | accelarray.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/accelarray.c b/accelarray.c new file mode 100644 index 0000000..293b841 --- /dev/null +++ b/accelarray.c @@ -0,0 +1,36 @@ +/* File: accelarray.c + Calculate the acceleration using arrays fora ccel and time using 11 points */ + +#include <stdio.h> +#include <math.h> + +#define M_G 9.81 +#define N 11 + +int main() +{ + double a[N],t[N]; + double mu=0.2; + double m = 5.0; + double p; + int i; + + double t0 = 0.0; + double tf = 10.0; + + for(i=0;i<N;i++) + { + t[i] = t0 + i*(tf-t0)/(N-1); + p = 4*sin(t[i]-3)+20; + a[i] = (p-mu*m*M_G)/m; + } + + printf("time(s) accel (m/s^2)\n"); + printf("--------------------\n"); + for(i=0;i<N;i++) + { + printf("%8.4f%5c%8.4f\n",t[i],'\0',a[i]); + } + return 0; + +} |
