Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When an object is falling because of gravity, the following formula can be used

ID: 3758838 • Letter: W

Question

When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period. D = ½ gt^2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time in second that the object has been falling. Write a function named fallingDistance 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. Write a program that demonstrates the function by calling it in a loop that passes the values 1 though 10 as arguments, and displays the return value.

This is a C++ Code.

Explanation / Answer

#include<iostream>

using namespace std;

float fallingDistance(float t) {
    //D = ½ gt^2 , g = 9.8
    float g = 9.8;
    float d = 0.5 * g * t * t;
    return d;
}

int main() {
    int i;
    for(i = 1; i <= 10; i++) {
        cout << "Time = " << i << " secs " << " falling distance = " << fallingDistance((float) i) << " meters" <<endl;
    }
}

Time = 1 secs   falling distance = 4.9 meters
Time = 2 secs   falling distance = 19.6 meters
Time = 3 secs   falling distance = 44.1 meters
Time = 4 secs   falling distance = 78.4 meters
Time = 5 secs   falling distance = 122.5 meters
Time = 6 secs   falling distance = 176.4 meters
Time = 7 secs   falling distance = 240.1 meters
Time = 8 secs   falling distance = 313.6 meters
Time = 9 secs   falling distance = 396.9 meters
Time = 10 secs   falling distance = 490 meters

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote