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
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
Get step-by-step solutions from verified subject matter experts
