#include <stdio.h>#include <string.h>
// Function to check if a string is palindromeint isPalindrome(char *str) {int len = strlen(str);for (int i = 0; i < len / 2; i++) {if (str[i] != str[len - i - 1]) {return 0;}}return 1;}
// Function to generate palindrome poem using input linevoid generatePalindromePoem(char *line) {// Split the line into wordschar *word = strtok(line, " “);while (word != NULL) {// Reverse the word and print itint len = strlen(word);for (int i = len - 1; i >= 0; i–) {printf(”%c", word[i]);}printf(" “);word = strtok(NULL, " “);}printf(”\n”);}
int main() {char line[100];
// Get input line from userprintf("Enter a line to generate palindrome poem: ");fgets(line, sizeof(line), stdin);// Remove newline character from inputline[strcspn(line, "\n")] = 0;// Check if input line is palindromeif (isPalindrome(line)) { // Generate palindrome poem generatePalindromePoem(line);} else { printf("Input line is not a palindrome.\n");}return 0;}




