Part E : 1. y(t)= y_o + v_yo*t+(1/2)*g*t^2 x(t)= x_o+v_xo*t t_2= - (2v_yo)/(g) W
ID: 1846833 • Letter: P
Question
Part E :
1. y(t)= y_o + v_yo*t+(1/2)*g*t^2
x(t)= x_o+v_xo*t
t_2= - (2v_yo)/(g)
Where y(t) is height of a projectile at any time t, x(t) is the horizontal distance covered in time t and t_2 is the time how long the projectile was in the air. Note that the air resistance is not considered for this problem. If the projectile is thrown at an initial speed v_o then
v_xo = v_o cos(theta) and v_yo = v_o sin(theta)
Write a C program to compute y(t) and x(t). start value of time t=0 seconds and maximum time t is t<=3.0 seconds (time increment= 0.137 seconds). This program should also write t, x(t), and y(t) (values only) in 3 consecutive columns of projectile.txt file respectively. This file should also contain a number of record/lines.
Given conditions: g= -9.81m/s^2 , v_o = 30m/s, x_o = 0m y_o = 45 (in degrees) and PI= 3.1415
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
float PI=3.1415;
float g=-9.81;
float v0=30.0;
float x0=0.0;
float y0=0.0;
float theta=45;
FILE *fp;
fp=fopen("projectile.txt","w+");
if(fp)
printf("hello");
float t=0.0;
float x,y;
x=0.0;
y=0.0;
float a;
a=sin(theta);
printf(" %f ",a);
theta=PI*theta/180;
fprintf(fp, "%f %f %f ",t,x,y);
while(t<=3)
{
t=t+0.137;
x=x0+v0*cos(theta)*t;
y=y0+v0*sin(theta)*t+0.5*g*t*t;
fprintf(fp, "%f %f %f ",t,x,y);
}
fclose(fp);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.