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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!