-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhght.cpp
More file actions
48 lines (30 loc) · 852 Bytes
/
hght.cpp
File metadata and controls
48 lines (30 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//======================================================
//returns the height ball reaches when subject to constant
//gravitational acceleration
//Arguments:
// g - gravitational acceleration
// v - initial velocity
// time - time at which height is desired
// =========================================================
#include <iostream>
using namespace std;
double hght(double g,double v,double time);
int main()
{
// set acceleration due to gravity
double g = 9.8;
cout<< "Input the initial velocity (m/s):> ";
double v0;
cin>> v0;
cout<<"Input the time (s):> ";
double t;
cin>> t;
cout<< " The height at time " << t << " is " << hght(g,v0,t) << endl;
return 0;
}
double hght(double g,double v,double time)
{
double h; //height ball will reach
h=v*time-g*time*time*0.5;
return h;
}