Language Fortran 90
Date: | 04/20/05 |
Author: | Akira Kida |
URL: | n/a |
Comments: | 2 |
Info: | n/a |
Score: | (2.95 in 40 votes) |
! F90 (Fortran 90) version of 99 bottles of beer. ! written by Akira KIDA, SDI00379@niftyserver.or.jp ! 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.' end
Download Source | Write Comment
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!
Comments
R said on 01/27/06 06:55:19
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
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.