Fortran

nested loops

nested loops program xytab implicit none !constructs a table of z=x/y for values of x from 1 to 2 and !y from 1 to 4 in steps of .5 real :: x, y, z print *, ' x y z' do x = 1,2 do y = 1,4,0.5 z = x/y print *, x,y,z end do end do end program xytab »

read file

okunan dosya burada program readdata implicit none !reads data from a file called mydata.txt real :: x,y,z open(5,file='mydata.txt') ! 5 burada C'deki file pointer yerine geciyor. read(5,*) x,y,z ! 5 burada C'deki file pointer yerine geciyor. print *,x,y,z end program readdata »

toplama

toplama program sum !a: name of program !an example of program structure !b: a comment real :: answer,x,y !c: declarations print *, 'Enter two numbers' !d: output read *, x !e: input read *, y !e: input answer=x+y !f: arithmetic print *, 'The total is ', answer !g: output end program sum !h: end of program »

write file

write file program io2 !illustrates writing arrays to files implicit none real :: num integer :: i open(12,file='myoutput.txt') !12 burada C'deki file pointer yerine geciyor. do i = 1,100 num = i/3.0 write(12,*) num !12 burada C'deki file pointer yerine geciyor. end do print *, 'finished' end program io2 »