Skip to content

Commit 89f7887

Browse files
Create find_max_height.cpp
This C++ program calculates the maximum height a ball will reach when thrown vertically upward with a given initial velocity. The program uses the standard equation of motion derived from basic physics: h = v 2 2 g h= 2g v 2 ​ where: 1. h is the maximum height (in meters), 2. v is the initial velocity of the ball (in meters per second), and 3. g is the acceleration due to gravity (9.8 m/s² on Earth). The user inputs the initial velocity, and the program computes and displays the corresponding maximum height. This program helps understand the relationship between velocity and height in projectile motion under uniform gravity.
1 parent b9c118f commit 89f7887

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

physics/find_max_height.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
double velocity, gravity = 9.8, maxHeight;
6+
7+
cout << "Enter the initial velocity of the ball (m/s): ";
8+
cin >> velocity;
9+
10+
maxHeight = (velocity * velocity) / (2 * gravity);
11+
12+
cout << "The maximum height the ball will reach is: " << maxHeight << " meters." << endl;
13+
14+
return 0;
15+
}

0 commit comments

Comments
 (0)