Wednesday, October 29, 2014

Plandrome Checker

Hi. I remember during first year of university when I was studying introduction to computer science course. It was a nice course where our professor taught us the basics of C++. The real fun was in solving problems related to numbers. There were few types of numbers that I was not aware of such as: palindromic numbers, perfect numbers. We were assigned to create simple looping programs where the user enters a number and the program has to check wether the number satisfies the conditions related to its type. Here I will share my code that checks wether an entered number is palindromic number or not. First, let's check the meaning of Palindrome in dictionary, and here what it says:

palindrome |ˈpalɪndrəʊm|
noun
a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam or nurses run.
DERIVATIVES
palindromic |-ˈdrɒmɪk| adjective,
palindromist noun

ORIGIN early 17th cent.: from Greek palindromos ‘running back again’, from palin ‘again’ + drom- (from dramein ‘to run’).

The following program was coded in Visual C++, .NET Framework 3.5 using Visual Studio 2010. If you are looking for a code in a different language, at least you can understand the concept of this code that I will explain directly after the following code:



The nice thing here is that I didn't use a variable to copy the entered number. The code starts pulling each digit from the right and append them to the left of the reversed number in each loop iteration

I hope that I brought something useful, or provided you with a solution for your homework. See you next time with more number types.