Home CPSC 340

Palindrome Checker

Objective

To practice file input, and strings in C++.


Task

For this lab, you will write a program that checks whether a particular string is a palindrome. A palindrome is a string that reads the same backwards as forwards. For example "Madam, I'm adam" or "Rise to vote Sir".

Your program will be given a file where the first line is the number of strings to check, and then there will be that many lines containing strings. Your program should check if each one is a palindrome, and print "Yes" or "No" to the screen.

In order to have your program ignore punctuation and space, you can use the following functions from the <cctype> library:


Details


Testing

You can use the input.txt file here to test your program. The correct output should be:

$ ./palindrome-tester
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes

Submitting

When your program works, email the code to ifinlay@umw.edu.

Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.