Palindrome meaning word, phrase that reads the same backwards as forwards. for example Madam, Kayak, radar, civic, refer. See below code to accept input from user and check.
/* Program Name: Check if given string is palindrome or not. ( Run Program in Turbo C)
*/
#include<stdio.h>
#include<string.h>
void main()
{
char str[50], str2[50];
printf("\n\nEnter String to Check if given string is palindrome or not:\t ");
scanf("%s",str);
//using strcpy function creating copy of string in string 2
strcpy(str2,str);
strrev(str2);
//This function is available in ANSI C compiler not in other.
//using strrev function reversing the string.
// now comparing both string to check if they are same or not.
if(strcmp(str,str2)==0)
printf("\n\nGiven String is Palindrome");
else
printf("\n\nGiven String is Not Palindrome");
}//main
Output
Enter String to Check if given string is palindrome or not: kayak
Given String is Palindrome
Enter String to Check if given string is palindrome or not: Software
Given String is Not Palindrome