CAS Community   >   Resources   >  

"The 00001100 Days of Christmas" in festive colour for Raspberry Pi - C++ using functions, constants, loops and arrays

Generates the lyrics to the 00001100 Days of Christmas using functions, arrays and iteration

Phil Gardner

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 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…

g++ 12-days-of-christmas.cpp

…which will make an executable a.out file.

To run…


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.

Downloaded 1393 times.


This resource has attached files: to access these files, please tick the box below to assent to the license terms
License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.

Feedback and Comments

Available when logged in (join via the front page, for free):
  • View 2 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.

All Rights Reserved © Computing At School 2020
Using the websiteDisclaimer of liabilityCookies policyPrivacy policy