<p>When an object is falling because of gravity, the following<br />formula can
ID: 3641882 • Letter: #
Question
<p>When an object is falling because of gravity, the following<br />formula can be used to determine the distance the object falls in a specific<br />time period.</p><p>D = ½ gt^2</p>
<p>The variables in the formula are as follows: d is the<br />distance in meters, g is 9.8, and t is the amount of time in second that the<br />object has been falling.</p>
<p>Write a function named fallingDistance that accepts an<br />object’s falling time (in seconds) as an argument. The function should return<br />the distance, in meters, that the object has fallen during that time interval.<br />Write a program that demonstrates the function by calling it in a loop that<br />passes the values 1 though 10 as arguments, and displays the return value.</p>
Explanation / Answer
#include<iostream>
using namespace std;
float fallingDistance(int time)
{
return (0.5*9.8* static_cast<float> (time));
}
int main()
{
cout << time in seconds " << " distnace in meters. << endl;
for(int i=1; i<=10; i++)
{
cout << i << " " << fallingDistance(i) << endl;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.