A cyclist coasting on a level road slows from a speed of 10 mi/ hr to 2.5 mi/ hr
ID: 3789557 • Letter: A
Question
A cyclist coasting on a level road slows from a speed of 10 mi/ hr to 2.5 mi/ hr in one minute. Write a computer program that calculates the cyclist’s constant rate of acceleration and determines how long the cyclist will take to come to rest, given an initial speed of 10 mi/ hr. Hint: Use the equation: a=vf-vi divided by t
where a is acceleration, t is time interval, vi is initial velocity, and vf is final velocity.) Write and call a function that displays instructions to the program user and a function that computes a, given t, vf and vi
Explanation / Answer
Here is the code:
#include <stdio.h>
void Calculate ( float initial_velocity, float final_velocity, float time );
int main()
{
float initial_velocity, final_velocity, time;
printf("Enter your cycling details to calculate the acceleration: ");
printf("Initial Velocity: ");
scanf("%f",&initial_velocity);
printf("Final Velocity: ");
scanf("%f",&final_velocity);
printf("Time: ");
scanf("%f",&time);
Calculate (initial_velocity, final_velocity, time );
return 0;
}
void Calculate ( float initial_velocity, float final_velocity, float time )
{
float acceleration;
acceleration = ( final_velocity - initial_velocity ) / time;
printf(" Acceleration: %.2f",acceleration);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.