A palindrome is a word which can be written in reversed order and it retains its meaning and spelling,Examples are lawal,ada,abba,etc
Write a simple QBASIC instruction that will accept a word from the keyboard and check if it is a palindrome or not. The palindrome must display a message showing if the word is palindrome or not.
Here's a simple QBASIC program that accepts a word from the keyboard and checks if it is a palindrome or not: ``` CLS INPUT "Enter a word: ", word$ n = LEN(word$) FOR i = 1 TO n / 2 IF MID$(word$, i, 1) <> MID$(word$, n - i + 1, 1) THEN PRINT word$; " is not a palindrome" END END IF NEXT PRINT word$; " is a palindrome" ``` Explanation: - `CLS` clears the screen before the program runs. - `INPUT` prompts the user to enter a word and stores it in the variable `word$`. - `n = LEN(word$)` gets the length of the word and stores it in the variable `n`. - The `FOR` loop checks each character of the word from the beginning to the middle of the word (i.e., `n/2`). If a character does not match its corresponding character from the end of the word, then the program prints a message saying that the word is not a palindrome and ends the program. - If the loop finishes without finding any mismatch, then the program prints a message saying that the word is a palindrome.