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

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.