Commit e16b3ca7 authored by Bruce Cowan's avatar Bruce Cowan

Nicer formatting of 'output' program, and automatic unit allocation

parent f5499dc9
Pipeline #2212 passed with stage
in 8 minutes and 8 seconds
program xproduct
implicit none
integer :: i, j
integer, parameter :: out_unit = 20
integer :: out_unit
print *,"Enter two integers"
read (*,*) i, j
open (unit = out_unit, file = "results", action = "write", status = "replace")
write (out_unit,*) "The product of", i, "and", j
write (out_unit,*) "is", i * j
! newunit from Fortran 2008
open (newunit=out_unit, file='results', action='write', status='replace')
write (out_unit, '(a, i0, a, i0)') "The product of ", i, " and ", j
write (out_unit, '(a, i0)') "is ", i * j
close (out_unit)
end program xproduct
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment