C Program to Check Whether a String is Palindrome or not

In this program, you'll learn to check a given string is Palindrome or not. A string is called Palindrome, if the original string and reverse string of original string are same. To check if a string is palindrome or not follow below steps: 1) Declare two string: f and r. 2) Find Reverse of string. 3) Check if the reversed string is equal to the given string.

Source Code
void main()
    int f, r, len=0;
    char str[20];
    printf("Enter the string: ");
    scanf("%s", str);

    // First calculate the length of string
    while(str[len] != '\0')

    f = 0;
    r = len-1;

    while(f <= r)
        if(str[f++] != str[r--])
            printf("String is not Palindrome");
    printf("String is Palindrome");
Enter the string: nitin
String is Palindrome

Enter the string: ramesh
String is not Palindrome