CAS Community   >   Resources   >  

Recursive Palindromes

Program that determines whether a string is a palindrome or not. Guess what it uses.

Phil Gardner

Created by Phil Gardner
last edited Oct 26 2018 by Phil Gardner

Simple C++ code that will compile on a Raspberry Pi, Linux PC or Mac using the free C++ compiler g++ (part of the GNU Compiler Collection and already on your Pi). Will also compile under Windows with the Code::Blocks IDE and compiler.

Compile from an IDE such as Geany or from the command line before running.

To compile from command-line:

    Save text in a file as palsource.cpp
    g++ -o palindrome palsource.cpp

To run the executable from the command-line:


Functions and calls, string handling, data-types. An opportunity for you to show students how programs can be compiled if you work with other languages e.g. Python. You can also compare and contrast the code with other languages - similar but different.

Level: I use this in GCSE classes, but you could demonstrate it working to Key Stage 3.

The pages were taken from a programming tutorial that I wrote in 2017: “Learn to Program Using C++ on the Raspberry Pi”. Available on Amazon. Over 200 programs and lots of theory that ties-in to GCSE or A-level.

More examples that you can use as demonstrations on my blog:

Downloaded 122 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 9 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.