Fortran - Exercise 2
module trig implicit none real, parameter :: pi = 3.1415992 contains real function degtorad(deg) real, intent(in) :: deg degtorad = deg*pi/180 end function degtorad real function radtodeg(rad) real, intent(in) :: rad radtodeg = rad*180/pi end function radtodeg end module trig program anglecov use trig implicit none real a,b,c, d,e,f ! read three angles read *, a, b, c ! Convert angles from degrees to radians d=degtorad(a); e=degtorad(b); f=degtorad(c) ! print the angles print *, d, e, f ! convert angles from radians to degrees print *, radtodeg(d), radtodeg(e), radtodeg(f) ! print the angles end program anglecov
Fortran - Vaja 2
module trig implicit none real, parameter :: pi = 3.1415992 contains real function degtorad(deg) real, intent(in) :: deg degtorad = deg*pi/180 end function degtorad real function radtodeg(rad) real, intent(in) :: rad radtodeg = rad*180/pi end function radtodeg end module trig program anglecov use trig implicit none real a,b,c, d,e,f ! preberi tri kote read *, a, b, c ! Pretvori kote iz stopinj v radiane d=degtorad(a); e=degtorad(b); f=degtorad(c) ! izpiši kote print *, d, e, f ! pretvori kote iz radianov v stopinje print *, radtodeg(d), radtodeg(e), radtodeg(f) ! izpiši kote end program anglecov