Step 1: Start
Step 2: Declare variables for original string, reversed string, length, and loop index
Step 3: Input the word from the user
Step 4: Find the length of the word
Step 5: Reverse the word and store it in another string
Step 6: Compare the original and reversed string
Step 7: If they match, print palindrome; otherwise, not palindrome
Step 8: End
#include <stdio.h> #include <string.h> int main() { char str[100], rev[100]; int length, i, isPalindrome = 1; printf("Enter a word: "); scanf("%s", str); length = strlen(str); // Reverse the string for (i = 0; i < length; i++) { rev[i] = str[length - i - 1]; } rev[length] = '\0'; // Null-terminate the reversed string // Compare original and reversed string for (i = 0; i < length; i++) { if (str[i] != rev[i]) { isPalindrome = 0; break; } } if (isPalindrome) { printf("'%s' is a Palindrome.\n", str); } else { printf("'%s' is NOT a Palindrome.\n", str); } return 0; }
Enter a word: radar 'radar' is a Palindrome. Enter a word: hello 'hello' is NOT a Palindrome.