| Lexington High School Mathematics | Math Dept. Front Page | Student Links | Family Links |
| Introduction to C++, Kevin Kelly | Kelly Front Page | C++ Course Guide | C++ Assignments | C++ Info |
A palindrome is a word or a phrase whose letters read the same forward or backward. Examples include the word level and the sentence Ma had a ham. (In the second example, note that capitalization, punctuation, and spacing are ignored. It's just the letters that matter; they are mahadaham, either forward or backward.)
Your assignment is to write and test a function
bool palindrome(apstring text)that returns true if the string text is a palindrome, and false if it is not.
For the basic part of the assignment, you may write a function that works only for inputs of a single word made of only lowercase letters. Here are the test values for this part of the assignment:
You may find it helpful to #include<ctype.h>
which enables various functions for determining the type of a character
(isalpha(c), isdigit(c), etc.)
and for converting cases (toupper(c), tolower(c)).
For a list of all of these functions, type man ctype at your command prompt,
or see this reference page.
Additional test values for the extensions: