Question: C++ Important notes: from now on, function prototypes should be written before the main function. And function definitions should be written after the main function.

C++

Important notes: from now on, function prototypes should be written before the main function. And function definitions should be written after the main function. 10% will be deducted if this is not obsereved.

a.) (Lab4a.cpp) Chapter 6, Falling Distance.

The following formula can be used to determine the distance an object falls in a specific time period:

C++ Important notes: from now on, function prototypes should be written befored=12gt2

where d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, the object has been falling.

Write a function named fallingDistance that accepts an object's falling time in seconds as an argument. You must define a named constant for g using a meaningful name and use that named constant in the calculation. G will not be an acceptable identifier. The function should return the distance, in meters, that the object has fallen during that time interval.

Check. The function prototype is near the top of the program above the main function.

Check. The function definition is below the main function.

Check. There is a comment box above the function definition that contains the description of the function, a description of the parameter variable, and a description of the return value. You can use the following text:

Name: fallingDistance

Description: This function returns the distance the falling object has traveled during a time interval.

Parameters:

interval - the time interval in seconds the object has traveled.

Return:

The distance in meters the object has traveled in the time interval.

From the main function, demonstrate the function by calling it in a for loop that passes the values 1 through 12 as arguments, and displays the return value.

The output should look exactly as follows (in single space):

the main function. And function definitions should be written after the main

Check. The output is identical to the requirement above.

2 2

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!