Generates the lyrics to the 00001100 Days of Christmas using functions, arrays and iteration
Created by Phil Gardner
last edited Dec 16 2016 by Phil Gardner
Converts the quantity of each festive gift to binary using a function.
The colour version will work on a Raspberry Pi, but not MinGW C++ under Windows. Colour version also uses the sleep() function to slow the program down rather than displaying the whole lot almost instantaneously.
For best results on a classroom projector, change the size of your font in the Terminal window (looks nice). On a Pi using LXTerminal, go to the Edit menu, choose Preferences and change font size to 22 (ish).
Standard C++ program that will compile and run on a Raspberry Pi. You can also compile it in Windows if you have MinGW or some other version of C++.
Raspberry Pi has the GNU Compiler Collection installed as part of the Debian or Raspbian operating system installations.
This C++ code can be compiled using the g++ compiler.
It is written using the C++ 98 standard so will compile on most Bronze Age settlements. Alternatively, you should be able to paste the code into repl.it web-site and run it there.
Comments are included to show you what each part of the code does if you have never seen any C++ before.
It was knocked up quickly yesterday for a bit of fun, but I have used more modern C++ style rather than older C-style features e.g. use of “cout” to display things on the screen, “endl” rather than ‘\n’ new-line characters.
Compile from command line in Linux using…
…which will make an executable a.out file.
Deluxe compilation option…
g++ -o song 12-days-of-christmas.cpp
…which will create an executable called song.
Not entirely pointless: functions, constants, arrays, iteration and output. Bonus.