This is an example in Fortran how to make a function:
program hello implicit none integer:: square integer:: i Print *,"write your number:" read *, i print *,"your number:",i i= square(i) print *,"your result:",i end program Hello integer function square( a ) implicit none integer :: a square = a*a end function square
Result:
write your number: 4 your number: 4 your result: 16