160k views
5 votes
Write a computer program that computes the duration of a projectile’s flight and its height above the ground when it reaches the target. As part of your solution, write and call a function that displays instructions to the program user. Note: Include functions in your program. Problem Constant G = 32.17 // gravitational constant Problem Inputs float theta // input - angle (radians) of elevation float distance // input - distance (ft) to target float velocity // input - projectile velocity (ft/sec) Problem Outputs float time // output - time (sec) of flight float height // output - height at impact

User Didster
by
5.9k points

1 Answer

3 votes

Answer:

#include <stdio.h> #define Gray 32.17 /* gravitational constant */ #include <math.h> /*cos definition*/ #define PI 3.14159265

int main(void) double Theta; /*input-angle(radians)of elevation*/ double Distance; /*input-distance (ft) to target */ double Velocity; /*input-projectile velocity (ft/sec)*/ double Time; /* output-time(sec) of flight*/ double Height; /*output-height at impact*/

printf("Enter Distance> "); scanf("%f", &Distance);

printf("Enter Radians> "); scanf("%f", &Theta);

printf("Enter Velocity> "); scanf("%f", &Velocity

Time = Distance / (Velocity * cos(Theta*PI/180.0) ) ;

Height = (Velocity *sin(Theta*PI/180.0)*Time) - Grav*(Time* Time) );

printf("The time of flight is %.3f seconds.\\", Time); printf("The height at impact is %.3f feets.\\", Height);

system("pause");

return (0);

User Muni
by
5.8k points