CSC 272 - Software II: Principles of Programming Languages

Dr. R. M. Siegfried

CSC 272:A FORTRAN program using a function

      real x, y, z, sum, total
c
      write(*, *) 'Enter a number'
      read(*, *) x
      write(*, *) 'Enter a number'
      read(*, *) y
      write(*, *) 'Enter a number'
      read(*, *) z
c
      total = sum(x, y, z)
      write(*, 501) x, y, z, total
  501 format(' The sum of ', 3(f10.3, 1x) 'is ', f10.3)
      end
c
c
c
      real function sum(a, b, c)
      real a, b, c, total
c
      total = a + b + c
      sum = total
      return
      end

[Back to the FORTRAN Index]