Fortran function example

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


 write your number: 
 your number:           4  
 your result:          16

3 thoughts on “Fortran function example”

  1. Thanks designed for sharing such a nice opinion, piece of writing is pleasant, thats why
    i have read it fully

  2. Hi there! This is my first visit to your blog! We are a collection of volunteers and starting a new project
    in a community in the same niche. Your blog provided us useful
    information to work on. You have done a outstanding job!

  3. We stumbled over here by a different page and thought I should check
    things out. I like what I see so i am just following you.
    Look forward to exploring your web page yet again.

Leave a Reply

Your email address will not be published.

three + 13 =