C++ problem with the effects of gravity

Hi, I'm trying to write a code to display the results of gravity on an object being dropped from a certain height. The user inputs the tower's height and the output should be a table displaying the effects of gravity on the object for every second. Example( 0s, 1s, 2s... ect.)
This is what I have so far.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
using namespace std;

int main()
{
	const double gravity=9.80665;
	int tower_height;
	double time;
	double distance=((gravity*time*time)/2);
	double height= tower_height - distance;

	while(distance <= tower_height && distance >=0)
	{
		cout<<"Enter the height of the tower: "<<endl;
		cin>> tower_height;

		height = tower_height - distance;

		cout<<"The height of the object at "<<time<<"/n is"<<height<<'m'<<endl;
		time++;
	}
	system("pause");
}
1
2
3
4
	int tower_height;
	double time;
	double distance=((gravity*time*time)/2);
	double height= tower_height - distance;


tower_height contains some random value, and so does time

distance is initialized by multiplying a constant times some random value and dividing by 2 which gives distance... some random value.

height is initialized by subtracting a random value from a random value.

Something tells me, our output is going to look random.

Do you really think you should be asking for input every iteration of the loop that's meant to display the table in question?

The loop condition depends on distance, but distance is never updated within the loop.
Topic archived. No new replies allowed.