Design an algorithm in pseudocode to determine whether any 5-letter word is a palindrome. Palindromes are words or sentences that read the same backward or forward. For example, “kayak” is a palindrome while “meter” is not. Ask the user to input 5 characters. You will need five separate variables to store these five characters. After obtaining the characters, compare the characters to determine if the word is a palindrome and output an appropriate message.
Since its Psudocode, I'll try to keep the code as general as possible.
Step 1: Get the word as input from the user
Since we store each letter in a seperate variable, we can write it as follows:
letter_1 = input()
letter_2 = input()
letter_3 = input()
letter_4 = input()
letter_5 = input()
Step 2: Check for palidrome
To check for palindrome, we need to check if the letter_1 and letter_5 are the same. Similarily for letter_2 and letter_4. Since its a five letter word, the middle letter doesnt matter for palindrome check.
if letter_1 equal to letter_5 and letter_2 equal to letter_4:
Print "Palindrome"
else:
Print "Not Palindrome"
Get Answers For Free
Most questions answered within 1 hours.