real language

Bookmarking Digg Diigo DZone Earthlink Google
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Fortran 90

Author:Akira Kida
Score: (2.97 in 39 votes)
!  F90 (Fortran 90) version of 99 bottles of beer.
!    written by Akira KIDA,
!    Note that this source is in FIXED format.

	program ninetynine
	implicit none
	integer, parameter :: BOTTLES = 99
	integer :: i
	integer :: k
	character*7 :: btl = 'bottles'

	do i = BOTTLES, 1, -1
		k = len(btl)
		if (i == 1) k = k - 1
		print *, i, btl(1:k), ' of beer on the wall, ',
     c			 i, btl(1:k), ' of beer.'
		print *, 'Take one down, pass it around.'
		if (i == 0) exit
		print *, i, btl(1:k), ' of beer on the wall.'
	end do
	print *, 'No more bottles of beer on the wall.'

Download Source | Write Comment

Alternative Versions


>>  R said on 01/27/06 06:55:19

R This code isn't correct.
The last line in the loop should print i-1
instead of i. Also, the test for changing
k from 7 to 6 should be moved down a few lines.

>>  Van Snyder said on 03/03/06 20:44:33

Van Snyder To make its format acceptable in both fixed and free form, put an ampersand in column 73 or later of the first line of the first print statement, and an ampersand in column 6 of the second line of that statement.

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!




Security Code: