Question: Write a program that computes how many feet an object falls in 1 second, 2 seconds, etc., up to 12 seconds. program should: 1. Have

Write a program that computes how many feet an object falls in 1 second, 2 seconds, etc., up to 12 seconds.

program should: 1. Have a procedure called FallingDistance which has one input parameter, seconds, and one output parameter, distance. 2. Compute the distance in feet an object falls using this formula: d = gt2 (where g = 32.2) 3. The main program should call FallingDistance within a loop which passes the values 1 through 12 as arguments. 4. Print a table with seconds and falling distance in feet

I did this on Visual Studios and when i debug it all my answers are zero, this is the program i came up with

#include #include using namespace std;

const double g = 32.2; double fallingdistance (int seconds=0);

int main() { int seconds = 0; double distance = 0;

cout << "Falling Distance ";

for (int i = 1; i <= 1; i++)

{ distance = fallingdistance(i); cout << i << "seconds:" << distance << "distance "; }

return 0; } double fallingdistance(int seconds);

{

distance = (.5* g) * (pow(seconds, 2)); return distance; }

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!