Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language FORTRAN IV

(a more elaborate version)

Date:02/03/10
Author:Johannes Schöön
URL:n/a
Comments:1
Info:n/a
Score: (2.96 in 27 votes)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

      PROGRAM BOTTLE

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C     THIS PROGRAM PRINTS THE ENTIRE LYRICS OF THE SONG - 99 BOTTLES OF
C     BEER - TO STANDARD OUTPUT. 
C
C     WARNING!: 
C     IT IS ASSUMED THAT INTEGERS USE FOUR BYTES OF STORAGE EACH.
C   
C     COPYRIGHT 2010 JOHANNES SCHOEOEN
C
C-----------------------------------------------------------------------

      DIMENSION   IBOBTW(7), IBOB(4), IT1DPI(8)

      DATA IBOBTW / 4H BOT, 4HTLES, 4H OF , 4HBEER, 
     &              4H ON , 4HTHE , 4HWALL /
      DATA IBOB   / 4H BOT, 4HTLES, 4H OF , 4HBEER / 
      DATA IT1DPI / 4HTAKE, 4H ONE, 4H DOW, 4HN AN, 
     &              4HD PA, 4HSS I, 4HT AR, 4HOUND /

C-----------------------------------------------------------------------

C     MOST OF THE OUTPUT IS GENERATED BY THIS LOOP, BUT THE LAST COUPLE
C     OF LINES ARE TREATED SEPARATELY. (YES, I CHEAT.)
      DO 1000 I = 99, 3, -1

C        ARITHMETIC IF STATEMENTS ARE USED TO DIFFERENTIATE BETWEEN 
C        DOUBLE- AND SINGLE-DIGIT OUTPUT.

C        FIRST LINE OF VERSE.
         IF (10 - I) 10, 10, 20
 10         WRITE (6, 9100) I, IBOBTW, 2H, , I, IBOB, 1H.
         GOTO 500
 20         WRITE (6, 9110) I, IBOBTW, 2H, , I, IBOB, 1H.

C        SECOND LINE.
 500     IF (11 - I) 30, 30, 40
 30         WRITE (6, 9200) IT1DPI, 2H, , I-1, IBOBTW, 1H.
         GOTO 1000
 40         WRITE (6, 9210) IT1DPI, 2H, , I-1, IBOBTW, 1H.

 1000 CONTINUE

C     PRINT OUT THE LAST COUPLE OF ROWS.
      WRITE (6, 9999)

      STOP

C     FIRST ROW OF VERSE, FIRST DOUBLE DIGIT, THEN SINGLE DIGIT.
 9100 FORMAT(1X, I2, 7A4, A2, I2, 4A4, A1)
 9110 FORMAT(1X, I1, 7A4, A2, I1, 4A4, A1)

C     SECOND LINE OF VERSE -- DOUBLE DIGIT AND SINGLE DIGIT
 9200 FORMAT(1X, 8A4, A2, I2, 7A4, A1, /)
 9210 FORMAT(1X, 8A4, A2, I1, 7A4, A1, /)

C     THE FINAL COUPLE OF ROWS, HARD-CODED FOR SIMPLICITY.
 9999 FORMAT(1X, 49H2 BOTTLES OF BEER ON THE WALL, 2 BOTTLES OF BEER.,/,
     &       1X, 50HTAKE ONE DOWN AND PASS IT AROUND, 1 BOTTLE OF BEER,
     &       13H ON THE WALL., //,
     &       1X, 47H1 BOTTLE OF BEER ON THE WALL, 1 BOTTLE OF BEER., 
     &       13H ON THE WALL., /,
     &       1X, 50HTAKE ONE DOWN AND PASS IT AROUND, NO MORE BOTTLES ,
     &       20HOF BEER ON THE WALL., //,
     &       1X, 37HNO MORE BOTTLES OF BEER ON THE WALL, ,
     &       24HNO MORE BOTTLES OF BEER., /,
     &       1X, 35HGO TO THE STORE AND BUY SOME MORE, ,
     &       31H99 BOTTLES OF BEER ON THE WALL.)
      END

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
1Allen Mcintosh04/20/051

Comments

>>  Jeff said on 05/02/10 04:48:51

Jeff Hmmm. Can't get it to go on FORTG or FORTH versions on a 370.
Neither like the negative DO increment.

Some references that state it's not part of the standard until Fortran 77.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: