81.2k views
4 votes
Another ball dropped from a tower A ball is again dropped from a tower of height h with initial velocity zero. Write a program that asks the user to enter the height in meters of the tower and then calculates and prints the time the ball takes until it hits the ground, ignoring air resistance. Use your program to calculate the time for a ball dropped from a 100 m high tower

User Hbogert
by
6.4k points

1 Answer

2 votes

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variable

double height;

// gravitational acceleration

double g=9.8;

cout<<"Please enter initial height:";

cin>>height;

// h=ut+(gt^2)/2

// here u, initial velocity is 0

// after simplification

double t=sqrt(2*height/g);

// print the time

cout<<"time taken by ball to hit the ground is:"<<t<<" seconds"<<endl;

return 0;

}

Step-by-step explanation:

Read the initial height from user. Declare and initialize the earth gravitational acceleration "g=9.8" .Then the equation is h=ut+(gt^2)/2, here u is initial velocity which is 0.Then after simplify the equation t=sqrt(2*h/g). Put the values in the equation and find the time taken by ball to hit the ground.

Output:

Please enter initial height:100

time taken by ball to hit the ground is:4.51754 seconds

User Andreas Daoutis
by
6.4k points