Question: Programming in C Assignment objectives: User Defined Functions Loops Math functions Write a program to calculate the trajectory of a cannon ball. The program must
Programming in C
Assignment objectives:
- User Defined Functions
- Loops
- Math functions
- Write a program to calculate the trajectory of a cannon ball. The program must ask the user for the initial velocity and initial trajectory angle then ask the user what they want to calculate, Time of flight or Max. Height or maximum horizontal range. Calculate what user wants and display the result plus the time that it takes to reach maximum height for any of the user choice.
Formulas:
Where Vo is the initial Velocity, sin is the component along y-axis, cos is the component along x-axis.
is initial angle of projectile
g is gravity in meter per second square
Note: cos and sin functions use radians as their unit for angles. See conversion below.
Solved Examples to calculate the above: (not a program)
A body is projected with a velocity of 20 m/sat 50o to the horizontal. Find (i) Maximum height reached (ii) Time of flight and (iii) Range of the projectile. Solution:
Initial Velocity Vo = 20 m/s, = 50o Time of flight, t = 2V0sing = 220sin5009.8 = 3.126 s. Maximum Height reached, H = V2osin22g = (20)2sin250229.8 = 11.97 m. Horizontal Range R = v20sin2g = 202sin100o9.8 = 40.196 m.
User input:
The initial velocity valid rage is 20 to 800 m/s
The initial angle valid range is 5 to 80 degrees
Requirement
Must implement functions for each of the followings:
- Calculating peak height. Must not print the result in the function
- Calculating max range. Must not print the result in the function
- Calculating travel time. Must not print the result in the function
- Check for valid input from the user and give the user chance to reenter the data until it is within the range.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
