List of Code Examples

note:  you should access the code examples from September 7th lecture by going to the lecture (which is #4)

 

FORTRAN

       Example1  

       Example2 – note that this is the one that would not compile correctly

 

     Here are some others to play with – they may or may not compile – see if you understand them

            Illustrates an array

            Illustrates use of end =

            Illustrates using integer division

            Illustrates use of an if statement

 

Code examples discussed in both classes – all of which illustrate

use of  computed go to statement.

            Example2v1     has hard coded value for I

            Example2v2     gets a single value from user for I

            Example2v3     loops and gets multiple values from user for I

            Example2v4     provides a better prompt

            Example2v5     illustrates use of ERR=  to keep program from bombing on incorrect input

 

Code examples discussed only in early class due to building evacuation

Silly                             

shows use of FORMAT statement to print only a label (10)

shows FORTRAN’s pass by reference parmeters

shows what used to happen when literals were passed as reference parameters

shows alternate FORMAT statements to print data in same way (12 and 13)

shows possible placement of SUBROUTINE subprogram in relation to calling  program

shows use of CALL statement to execute SUBROUTINE

            MySub

                        shows use of CALL statement 

shows possible placement of SUBROUTINE subprogram in relation to calling   program

                        shows use of continuation card

                        shows SUBROUTINE to swap two numbers

                        shows that a blank line is okay

                       

Code example NOT discussed in class which doesn’t produce desired output.  See if you can figure out what’s wrong

                        example