projectile motion program C-min

Write code in C to find the max height reached, max horizontal range reached, and total time of travel by a projectile projected with an angle theta with horizontal. The user will provide the angle when prompted, and then the program will calculate the results and show the results.

Program in C to find max height, total time, and range of Projectile

Code

#include <stdio.h>
#include <math.h>
int main() {
double g = 9.81; // Acceleration due to gravity (m/s^2)
double theta; // Angle of projection in degrees
double v0; // Initial velocity of the projectile (m/s)

printf("Enter the angle of projection (in degrees): ");
scanf("%lf", &theta);

printf("Enter the initial velocity (in m/s): ");
scanf("%lf", &v0);

// Convert angle from degrees to radians
double theta_rad = theta * M_PI / 180.0;

// Calculate time of flight
double t_flight = (2.0 * v0 * sin(theta_rad)) / g;

// Calculate max height reached
double max_height = (v0 * v0 * sin(theta_rad) * sin(theta_rad)) / (2.0 * g);

// Calculate max horizontal range
double max_range = (v0 * v0 * sin(2.0 * theta_rad)) / g;

printf("Results:\n");
printf("Max Height Reached: %.2f meters\n", max_height);
printf("Max Horizontal Range: %.2f meters\n", max_range);
printf("Total Time of Travel: %.2f seconds\n", t_flight);

return 0;
}
error: Content is protected !!