FORTRAN

FORTRAN is a contraction of Formula Translation, a name that 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, it was not designed for its beauty (a reasonable statement) but 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 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