
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A programming assignment for csci 270 students in the fall 2004 semester. The assignment focuses on writing a recursive function and a function template to test if an array is a palindrome, which reads the same forward and backward, regardless of the array's character type. The document also includes instructions for creating a test driver program to read character strings from a file and output palindromes.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Fall 2004 Due: Thursday, 4 Nov
Emphasis on: Using Recursion and Templates to Detect Palindromes
In this assignment you will be asked to write a recursive function that tests whether an array of characters is a palindrome. You will then rewrite the function as a function template so that you can determine if an array of any type (e.g. arrays of int, float, bool) are palindromes.
A palindrome in the context of english words is a word that reads the same forward and backward. For instance, the following are palindromes:
dad level did madamimadam
A couple of hints to get you started. An array with 0 or 1 characters will be defined to be a palindrom (e.g. stopping condition). If the first and last characters of the array are equal, then it is a palindrome provided the string in between the ends is also a palindrome.
Part A: Write a recursive function that accepts an array of characters (and possibly other parameters) and determines if the character array is a palindrome as defined above. The function should return a bool result that is true if it is a palindrome and false otherwise.
Part B: Modify your function from part A to turn it into a function template. Thereby allow your palindrome testing function to test not only if an array of characters is a palindrome, but also arrays of ints, floats, etc.
Part C: Write a test driver program that will read in character strings from a file. The input file will have 1 word per line. You should read in each line as a character array then test if it is a palindrome. If the line is a palindrome write it back out to standard output.
Requirements
type of array.