Question
Copy your repaired version of the gravity.c file from your Lab2 directory. Modify the program to read the time from the user as a float
Copy your repaired version of the gravity.c file from your Lab2 directory. Modify the program to read the time from the user as a float value and compute the distance and speed of the falling object. (Don't forget to prompt the user for input).
main() { float gravity, distance, velocity; int time;
/* set the time */ time = 10; gravity = 32;
/*print title*/ printf("***velocity and distance*** ");
/* compute the velocity */ velocity = gravity * time;
/* compute the distance */ distance = gravity * time * time / 2;
/* print the result */ printf("An object falling %f feet in %d seconds ", distance, time); printf("is traveling %f ft/sec ",velocity); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started