Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Position of a projectile at anytime t, fired with a speed of v0 = 162 m/s at angle angle = 70 is given by: x(t)

Position of a projectile at anytime t, fired with a speed of v0 = 162 m/s at angle angle = 70 is given by:

x(t) = v0*t*cos

y(t) = v0*t*sin - 0.5*g*t^2 where g = 9.81 m/s^2

Write a C code that writes in a file the coordinates x(t). y(t) of the projectile in increments of t 0.01 s

When the projectile is fired at t= 0, its coordinates are x(0) = 0 and y(0) = 0. When the projectile falls back to the ground, its coordinates will be again zero. Since you do not know how much time it will take for the projectile to return to the ground, you need to allow for a sufficiently long duration, of the order of 30s to 40s. The code should stop writing coordinates to the file when the projectile reaches the ground (negative y(t) shoud not be allowed).

In order to write the values to a file, your code should declare a file variable, should open the file, should write to the file, and should close the file at the end of the code.

To declare a file (myresults is a pointer to a file):

FILE *myresults;

To open a file for writing (the filename is results.dat):

myresults = fopen("results.dat", "w");

To close the file:

fclose(myresults);

To write to the file (e.g., the value of the real variable a):

fprintf(myresults,"%f ",a);

You should turn in your code and the plot of the projectiles path generated from the data you wrote to the results.dat file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions