[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Intrinsic functions
pradeepDate: Saturday, 05 April 14, 3:09 PM | Message # 1
pk
Group: Administrators
Messages: 82
Status: Offline

Code
program projectile
implicit none
! define constants
real, parameter :: g = 9.8
real, parameter :: pi = 3.1415927
real :: a, t, u, x, y
real :: theta, v, vx, vy
! Read values for a, t, and u from terminal
read(*,*) a, t, u
! convert angle to radians
a = a * pi / 180.0
x = u * cos(a) * t
y = u * sin(a) * t – 0.5 * g * t * t
vx = u * cos(a)
vy = u * sin(a) - g * t
v = sqrt(vx * vx + vy * vy)
theta = atan(vy / vx) * 180.0 / pi
write(*,*) ’x: ’,x,’ y: ’,y
write(*,*) ’v: ’,v,’ theta: ’,theta
end program projectile
 
  • Page 1 of 1
  • 1
Search: