Lesson topics
Demo 1
program average
c This program averages two numbers input by the user.
c It prints the results to a file.
real x, y, avg
print *, "Enter your first number :"
read *, x
print *, "Enter your second number :"
read *, y
avg = (x + y)/2.
open (unit = 1 , file = "result")
write (1,*) "Your requested average is in the table below."
write (1,*)
write (1,10) "First Number", "Second Number", "Average"
10 format (t10,a,t30,a,t50,a)
write (1,*)
write (1,20) x, y, avg
20 format (t10,f8.2,t30,f8.2,t48,f8.2)
print *
print *, "To see the average, open the file 'result'"
print *, "Bye"
end