PHYSICS 580 Spring 2005
Fortran Example #5 due
Write a short program that print out an angle (in degrees)
and the sine of the angle. Loop over some set of angles (the range is not
important). Format the output so that it
is in neat columns. Also include in the format “ Angle
=” and “ sine(angle) = “ so that the output looks like
For angle 10 degrees the sine is 0.2111
For angle 20 degrees the sine is 0.2344
For angle 30 degrees the sine is 0.2702
The exact formatting is not important, but it should look neat. You must use a format statement. The output should be written to the screen (unit 6).
Extra Fortran Practive (do NOT turn in)
Opening and closing files
Write a program to do the following:
(a) Ask for the name (e.g. filename) of a file
(b) Open a file filename.exm (that is the user supplies filename and the program adds the suffix .exm)
(c) Read three integers there.
(d) Close filename.exm and open a new file filename.new
(e) Add the three integers, write to filename.new, and close it.
Try your program by creating using an editor the original file filename.exm.
You may “borrow” code from my example 23.