How to resolve the algorithm 99 bottles of beer step by step in the BCPL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm 99 bottles of beer step by step in the BCPL programming language
Table of Contents
Problem Statement
Display the complete lyrics for the song: 99 Bottles of Beer on the Wall.
The lyrics follow this form: ... and so on, until reaching 0 (zero). Grammatical support for 1 bottle of beer is optional. As with any puzzle, try to do it in as creative/concise/comical a way as possible (simple, obvious solutions allowed, too).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm 99 bottles of beer step by step in the BCPL programming language
Source code in the bcpl programming language
get "libhdr"
let number(n) be
test n=0
then writes("No more")
else writen(n)
let plural(n) be
test n=1
then writes(" bottle")
else writes(" bottles")
let bottles(n) be
$( number(n)
plural(n)
$)
let verse(n) be
$( bottles(n)
writes(" of beer on the wall,*N")
bottles(n)
writes(" of beer,*NTake ")
test n=1
then writes("it")
else writes("one")
writes(" down and pass it around,*N")
bottles(n-1)
writes(" of beer on the wall!*N*N")
$)
let start() be
for n = 99 to 1 by -1 do verse(n)
You may also check:How to resolve the algorithm Arithmetic/Complex step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Lily programming language
You may also check:How to resolve the algorithm RPG attributes generator step by step in the jq programming language
You may also check:How to resolve the algorithm Sum and product of an array step by step in the Elixir programming language
You may also check:How to resolve the algorithm Go Fish step by step in the AutoHotkey programming language