How to resolve the algorithm The Twelve Days of Christmas step by step in the Seed7 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 Seed7 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 Seed7 programming language
Source code in the seed7 programming language
$ include "seed7_05.s7i";
const proc: main is func
local
const array string: gifts is [] (
"A partridge in a pear tree.", "Two turtle doves and",
"Three french hens", "Four calling birds",
"Five golden rings", "Six geese a-laying",
"Seven swans a-swimming", "Eight maids a-milking",
"Nine ladies dancing", "Ten lords a-leaping",
"Eleven pipers piping", "Twelve drummers drumming");
const array string: days is [] (
"first", "second", "third", "fourth", "fifth", "sixth",
"seventh", "eighth", "ninth", "tenth", "eleventh", "Twelfth");
var integer: day is 0;
var integer: gift is 0;
begin
for day range 1 to length(days) do
writeln;
writeln("On the " <& days[day] <& " day of Christmas,");
writeln("My true love gave to me:");
for gift range day downto 1 do
writeln(gifts[gift]);
end for;
end for;
end func;
You may also check:How to resolve the algorithm Esthetic numbers step by step in the Delphi programming language
You may also check:How to resolve the algorithm Sierpinski carpet step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Strong and weak primes step by step in the Perl programming language
You may also check:How to resolve the algorithm Priority queue step by step in the Maxima programming language
You may also check:How to resolve the algorithm Substitution cipher step by step in the Wren programming language