How to resolve the algorithm The Twelve Days of Christmas step by step in the uBasic/4tH programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm The Twelve Days of Christmas step by step in the uBasic/4tH programming language
Table of Contents
Problem Statement
Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas.
The lyrics can be found here.
(You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.)
Let's start with the solution:
Step by Step solution about How to resolve the algorithm The Twelve Days of Christmas step by step in the uBasic/4tH programming language
Source code in the ubasic/4th programming language
Dim @n(12) : Dim @v(12) ' define both arrays
Proc _DataDays ' put data on the stack
For i=11 To 0 Step -1 ' read them in
@n(i) = Pop()
Next
Proc _DataGifts ' put data on the stack
For i=11 To 0 Step -1 ' read them in
@v(i) = Pop()
Next
For i=0 To 11 ' print all twelve verses
Print "On the ";Show(@n(i));" day of Christmas"
Print "My true love gave to me:"
For j=i To 0 Step -1 ' show list of gifts
Print Show(@v(j))
Next
Print ' next verse
Next
End
_DataDays
Push "first", "second", "third", "fourth"
Push "fifth", "sixth", "seventh", "eighth"
Push "ninth", "tenth", "eleventh", "twelfth"
Return
_DataGifts
Push "A partridge in a pear tree."
Push "Two turtle doves and"
Push "Three french hens"
Push "Four calling birds"
Push "Five golden rings"
Push "Six geese a-laying"
Push "Seven swans a-swimming"
Push "Eight maids a-milking"
Push "Nine ladies dancing"
Push "Ten lords a-leaping"
Push "Eleven pipers piping"
Push "Twelve drummers drumming"
Return
You may also check:How to resolve the algorithm Perfect numbers step by step in the Groovy programming language
You may also check:How to resolve the algorithm Array concatenation step by step in the Oforth programming language
You may also check:How to resolve the algorithm Find common directory path step by step in the MapBasic programming language
You may also check:How to resolve the algorithm Averages/Median step by step in the K programming language
You may also check:How to resolve the algorithm A+B step by step in the BlooP programming language