The following formula can be used to determine the distance
The following formula can be used to determine the distance an object falls due to gravity in a specific time period: d = (0.5)*g*pow(t, 2). The variables in the formula are as follows: d is the distance in meters and will be computed, g is acceleration due to gravity and is 9.8m/s^2, and t is the time in seconds that the object has been falling. Create a function named falling Distance that accepts an object\'s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Create a program with this function inside of a loop that passes the values of time 1 through 10 seconds as arguments to the function. A new value of t is passed into the function each time the loop is repeated with a new value of t as the argument to the function. Return value of the distance fallen in a court statement that indicates the distance fallen for the corresponding value of t.
Solution
Hope this helps...
Please find the required functions and a cout statement which prints the result for each time value from 1 to 10 secs.
#include<bits/stdc++.h>
#define endl \'\ \'
using namespace std;
float fallingDistance(int time)
{
float d=4.9*pow(time,2);
return d;
}
int main()
{
for(int i=1;i<=10;i++)
{
cout<<\"For time = \"<<i<<\" Distance is \"<<fallingDistance(i)<<endl;
}
return 0;
}
