

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A homework assignment for a fortran programming course. It includes exercises on the difference between comments, variable declarations, and executable statements, as well as calculations using fortran expressions and the factorial function.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


(a) (2.0 + 3.02) / (8.0-2.0+1.0) (b) (2.0+3.0)2 / (8.0-2.0+1.0) (c) 3.0/5.0 + 2.0 ** 3 (d) 3/5 + 2**
program test implicit none real :: x=3. integer :: i= x = x/(x-1.0)2(-1)-1. i = i + 1/i- print *, x,i stop end program test
m = n - (n/2)*
f =
1 .0 + cos^2 x (1.0 + x^3 )(1 − x^2 )
program factorial implicit none integer :: x, fct integer, parameter :: cutoff = 100
do read *, x if (x < 0) then exit elseif (x<cutoff) then fct = 1 do i = 1,x fct = fct * i enddo print *,fct else print *,’Number too big’ endif enddo
stop program factorial
Hints Be careful about interpreting the types of constants, and remember that integer division is chopped. You need not write actual code and run them, but feel free to do so if you want to make sure of your answers. You need not hand in the programs.