CPPForSchool.com: String Set 1 Assignment 6

6. Write a program to check a string is palindrome or not.

According to Merriam Webster's Online Dictionary:

Palindrome: a word, verse, or sentence, or a number that reads the same backward or forward.
For example: 1881, madam, "Able was I ere I saw Elba"


This assignment was quite the eye opener.  My original approach was to place the string in backwards order within a separate string and then compare values.  Unfortunately, it did not work.  Concept wise, it seemed like a solid approach.  However, when practiced, it appears that there are some additional hurdles to overcome.  Nevertheless, the first set of screenshots demonstrates my first source code and output, which shows the downfall of the approach.  For some reason, when the second string array acquired the same characters, there seems to be some additional artifacts that comes along with it.  This results in a false interpretation of the contents of the string array.







There seems to be some additional processes occurring that exceeds my current comprehension of C++.  Regardless, I went ahead and reviewed the sample source code and successfully coded the assignment.  Everything is now working as designed.  However, this is a clear example of how much I need to learn with C++ before I can actually feel like a confident programmer.  Below are screenshots of my source code, output, and the sample source code and output.  It is important to note that the new approach is to simple review half of the string and then compare it with the rest.  This results in faster processing time and no longer requires an additional array for temporary storage.














Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8