Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project 1 Basic I/C Overview In this project you will begin to explore the basic

ID: 2248080 • Letter: P

Question

Project 1 Basic I/C Overview In this project you will begin to explore the basics of input and output from a C program I order to perform error checking and to provide a robust, teractive program, you will also get to grips with looping andconditionals. Additionally, you will get some practice using Makefiles and the compiler Submission Instructions This and all other assignments will be submitted through BBLean Look for the submission ink in the same place you found this assignment Submit all your c and h files along with your Makefile, but do not zip them! Technical Description and Instructions Your program will take some inputs from the user and use them to perfom a ballistic calculation, that is it will calculate how long it would take for a lanched object to hit the ground and how far the launched object went. Specifically will prompt the user for a starting height above the ground for the object, the angle of launch, and the initial launch velocity. Once good inputs have been collected, your program will then display the time and distance results to the user Note that your program may be evaluated by a program I compose for just this purpose. As such, when the instructions indicate that something should be printed in a certain way, failing to do so may cause my evaluator to reject your program!

Explanation / Answer

#include <stdio.h>

#include <math.h>

#define PI 3.14159265

int main()

{

float ini_h=-1;

float angle=-91;

float ini_v=-1;

float time,time_v;

float V_x,V_y,height;

float val=PI/180.0;

float distance;

printf("HI, WELCOME TO BALLISTICS PROGRAM ");

while(ini_h<0)

{

printf("Enter initial height above the ground in meters: ");

scanf("%f",&ini_h);

if (ini_h<0)

{

printf("Unable to accept negative starting height ");

fflush(stdin);

}

}

while (angle>90 | angle <-90)

{

printf("Enter angle of the projectile ");

scanf("%f",&angle);

if (angle>90 | angle<-90)

{

printf("please enter angle between 90 and -90 degrees only ");

}

}

while(ini_v<0)

{

printf("Enter initial velocity: ");

scanf("%f",&ini_v);

if (ini_v<0)

{

printf("Unable to accept negative velocity ");

fflush(stdin);

}

}

V_x = ini_v * cos(angle*val);

if (angle>0)

{

V_y = ini_v * sin(angle*val);

height=(V_y*V_y)/(2*9.8);

time_v=height/V_y;

time=time_v+sqrt(2*height/9.8);

}

else if (angle<=0)

{

V_y=ini_v * cos ((90-angle)*val);

time=sqrt(2*ini_h/9.8);

}

printf(">%f %f %f ",V_x,V_y,time_v);

distance=V_x*time;

printf("Time=%.4f and Distance=%.4f ",time,distance);

return 0;

}