/* June 3, 1998 */ /* program to compute duration of flight and height of projectile */ #include#include #define G 32.17 /* Definition of G */ /* Function prototypes */ void instruct (void); double get_time (double dist, double vel, double theta); double get_height (double vel, double theta, double time); main () { /* declarations */ double theta, vel, dist, time, height; /* function call to display instructions */ instruct(); /* request for user's input */ printf("Enter angle of elevation in radians> "); scanf("%lf", &theta); printf("Enter velocity in ft/sec> "); scanf("%lf", &vel); printf("Enter distance to target in ft> "); scanf("%lf", &dist); /* function call to display time */ time = get_time(dist, vel, theta); printf(" \n"); printf("Duration of flight is %.3f sec \n", time); /* function call to display height */ height = get_height(vel, theta, time); printf(" \n"); printf("Height above ground when it reaches target is %.3f ft \n", height); } /* function definition */ double get_time (double dist, double vel, double theta) { /* declaration */ double time; /* computation */ time = dist / (vel * cos(theta)); return (time); } double get_height(double vel, double theta, double time) { /* declaration */ double height; /* computation */ height = vel * sin(theta) * time - ((G * time * time) / 2); return (height); } void instruct(void) { /* display instructions */ printf(" \n"); printf("Instructions \n"); printf("------------ \n"); printf("Input angle of elevation, distance and velocity \n"); printf(" \n"); }