Reference no: EM13161325
A palindrome is a number or text phrase that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 34543 and 11611. Write a program that reads in a five-digit integer and determines whether or not it is a palindrome.
Solving Steps:
Use integer division method (similar to the Excel Assignment Question 4) to solve the problem.
Part 2:
Write a program that checks whether the string given by the user is Palindrome or not.
A string can be said as a Palindrome in the case when you reverse the string and gives the same original string. For example think of a word like ABCCBA:
Original String: ABCCBA
Reverse String: ABCCBA
So both the original and the reverse match each other, so the string is a Palindrome.
In this problem only one word will be used and you need to check whether the word is a palindrome or not. Do not use any built-in functions; use the technique defined below.
How to check whether the string is palindrome or not:
str[0] str1 [1] str1 [2] str1 [3] str1 [4] str1 [5]
A B C C B A
i=0 j=5
Solving Steps:
Compare the character of str[i] and str[j]
Increment i++ (by 1) and Decrement j-- (by1)
Stops when i and j are equal or j<i