Skip to content

Instantly share code, notes, and snippets.

@guaracy
Last active November 3, 2016 13:47
Show Gist options
  • Save guaracy/c4e240d68f4894d01c14 to your computer and use it in GitHub Desktop.
Save guaracy/c4e240d68f4894d01c14 to your computer and use it in GitHub Desktop.
identification division.
program-id. 99-bottles.
data division.
working-storage section.
77 max pic 9(02) value 99.
77 bottle-word pic x(07).
77 bottles pic 99.
88 too-drunk value 0.
procedure division.
perform varying bottles from max by -1 until too-drunk
if bottles = 1
move "bottle" to bottle-word
else
move "bottles" to bottle-word
end-if
if bottles not equal max
display "Take one down and pass it arround"
display bottles " " bottle-word " of beer on the wall."
display " "
end-if
display bottles " " bottle-word " of beer on the wall"
display bottles " " bottle-word " of beer"
end-perform.
display "Take one down and pass it arround"
display "No more bottles of beer on the wall."
display " "
display "Go to the store and buy some more "
display max " bottles of beer on the wall.".
stop run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment