Program that determines whether a string is a palindrome or not. Guess what it uses.
Created by Phil Gardner
last edited Mar 22 2021 by Phil Gardner
Stop-press! I’ve added an excerpt from “Learn to Program Using C++ on the Raspberry Pi” that explains how the program works. Well alright then.
Paste C++ code into replit.com then run.
Simple C++ code 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 pal palsource.cpp To run the executable from the command-line: ./pal
Uses: Functions and calls, string handling, data-types, recursion.
Level: I use this in GCSE classes, but you could demonstrate it working to Key Stage 3.
More examples on blog: https://program-using-gnu-cpp.blogspot.com