I have a task that I have to submit immediately.OK,here are the instructions.
Creating a programme for parabolic path/parabolic motion.
-The object is shot from the ground and there must be 4 input datas : the duration of time (t),the angle,initial velocity and the time interval of the displacement(delta t).
-The output should be the displacement in both the x and y direction.
- projection time is set to 0
- the position after t seconds is calculated by delta t second intervals(t and delta t is also input after the program runs).
- the result is output to the file, use Excel to make graph with it
I am having problems with writing the equations correctly and also with t and delta t
Here's what I have done so far.Someone correct me please.
Here's the results.It came out endless and with weird resultsCode:#include <stdio.h> #include <math.h> #define g 9.8 int main() { double t, x, y, angle, Vo, deltat; char buf[256]; int i; FILE* fp; printf( "t = " ); fgets( buf, 256, stdin ); sscanf( buf, "%lf\n", &t ); printf( "deltat = " ); fgets( buf, 256, stdin ); sscanf( buf, "%lf\n", &deltat ); printf("initial velocity = "); sscanf( buf, "%lf\n", &Vo ); fgets( buf, 256, stdin ); printf( "angle = " ); sscanf( buf, "%lf\n", &angle ); fgets( buf, 256, stdin ); fp = fopen( "z:\\FreeFall.txt", "w" ); for( i = 0; i < t; 'i+=deltat' ) { y = Vo*sin(angle)*deltat - ( g / 2.0 ) *deltat * deltat; x = Vo*cos(angle)*deltat; printf( "i= %f, y= %f ,x= %f\n", t, y, x ); fprintf( fp, "i=, %f, y=, %f ,x= %f\n", t, y, x ); } fprintf( stderr, "File z:\\FreeFall.txt was created\n" ); fclose( fp ); return 0; }
![]()



2Likes
LinkBack URL
About LinkBacks



