O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FORTRAN

FORTRAN is a contraction of Formula Translation, the name of which comes from a technical report entitled “The IBM Mathematical FORmula TRANslating system” written by John Backus and his team at IBM in the mid 1950s. FORTRAN is primarily designed for scientific calculations and has the distinction of being the first widely used high-level programming language. Backus made some rather interesting claims about FORTRAN: for instance, that it was not designed for its beauty (a reasonable statement), but that it would eliminate coding errors and the consequent debugging process!

Here is the FORTRAN version of our little averaging program. Lines that begin with a C in column one are comments:

	C FORTRAN PROGRAM TO COMPUTE THE AVERAGE
	C OF A SET OF AT MOST 100 NUMBERS

	        Real SUM, AVE, NEXTNUM
	        SUM = 0.0

	C Ask for the number of numbers
	        WRITE(*,*) 'Enter the number of numbers: '
	        READ(*,*) NUM

	C If Num is between 1 and 100 then proceed
	        IF NUM .GT. 0 .AND. NUM .LE. 100 then
	            C Loop to collect the numbers to average
	            DO 10 I = 1, NUM
	                C Ask for next number
	                WRITE(*,*) 'Enter next number: '
	                READ(*,*) NEXTNUM
	                C Add the number to the running sum
	                SUM = SUM + NEXTNUM
	10          CONTINUE
	            C Compute the average
	            AVE = SUM/NUM
	            C Display the average
	            WRITE(*,*) 'The average is: '
	            WRITE(*,*) AVE
	        ENDIF

	        STOP
	        END

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required