How to resolve the algorithm Old lady swallowed a fly step by step in the Elena programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Old lady swallowed a fly step by step in the Elena programming language
Table of Contents
Problem Statement
Present a program which emits the lyrics to the song I Knew an Old Lady Who Swallowed a Fly, taking advantage of the repetitive structure of the song's lyrics. This song has multiple versions with slightly different lyrics, so all these programs might not emit identical output.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Old lady swallowed a fly step by step in the Elena programming language
Source code in the elena programming language
import extensions;
const Creatures = new string[]{"fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"};
const Comments = new string[]
{
"I don't know why she swallowed that fly"$10"Perhaps she'll die",
"That wiggled and jiggled and tickled inside her",
"How absurd, to swallow a bird",
"Imagine that. She swallowed a cat",
"What a hog to swallow a dog",
"She just opened her throat and swallowed that goat",
"I don't know how she swallowed that cow",
"She's dead of course"
};
public program()
{
for(int i := 0, i < Creatures.Length, i += 1)
{
console
.printLineFormatted("There was an old lady who swallowed a {0}",Creatures[i])
.printLine(Comments[i]);
if(i != 0 && i != Creatures.Length - 1)
{
for(int j := i, j > 0, j -= 1)
{
console.printLineFormatted("She swallowed the {0} to catch the {1}",Creatures[j],Creatures[j - 1])
};
console.writeLine(Comments[0])
};
console.writeLine()
}
}
You may also check:How to resolve the algorithm Terminal control/Inverse video step by step in the Nim programming language
You may also check:How to resolve the algorithm Hello world/Standard error step by step in the sed programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Enguage programming language
You may also check:How to resolve the algorithm Sum digits of an integer step by step in the TypeScript programming language
You may also check:How to resolve the algorithm Classes step by step in the Swift programming language