Program that determines whether a string is a palindrome or not. Guess what it uses.
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: ./palindrome
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: https://program-using-gnu-cpp.blogspot.com