How to resolve the algorithm The Twelve Days of Christmas step by step in the Action! 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 Action! 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 Action! programming language

Source code in the action! programming language

PROC Wait(BYTE frames)
  BYTE RTCLOK=$14
  frames==+RTCLOK
  WHILE frames#RTCLOK DO OD
RETURN

PROC Main()
  DEFINE PTR="CARD"
  PTR ARRAY num(12),obj(12)
  BYTE i,j

  num(0)="first" num(1)="second" num(2)="third"
  num(3)="fourth" num(4)="fifth" num(5)="sixth"
  num(6)="seventh" num(7)="eight" num(8)="ninth"
  num(9)="tenth" num(10)="eleventh" num(11)="Twelfth"

  obj(0)="And a partridge in a pear tree."
  obj(1)="Two turtle doves"
  obj(2)="Three french hens"
  obj(3)="Four calling birds"
  obj(4)="Five golden rings"
  obj(5)="Six geese a-laying"
  obj(6)="Seven swans a-swimming"
  obj(7)="Eight maids a-milking"
  obj(8)="Nine ladies dancing"
  obj(9)="Ten lords a-leaping"
  obj(10)="Eleven pipers piping"
  obj(11)="Twelve drummers drumming"

  FOR i=0 TO 11
  DO
    PrintF("On the %S day of Christmas,%E",num(i))
    PrintE("My true love gave to me:")
    IF i=0 THEN
      PrintE("A partridge in a pear tree.")
    ELSE
      j=i+1
      WHILE j>0
      DO
        j==-1
        PrintE(obj(j))
      OD
    FI
    PutE()
    Wait(50)
  OD
RETURN

  

You may also check:How to resolve the algorithm Reverse words in a string step by step in the Go programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Chaos game step by step in the Gnuplot programming language
You may also check:How to resolve the algorithm Terminal control/Preserve screen step by step in the Tcl programming language