C program to check whether a string is palindrome or not || string manipulation in C || C programming

In this,we are going to see a program which checks whether the inputted string is Palindrome or not  using an in-built function of string.h header file in C Programming Language. 

//Checking whether the string is Palindrome or not
//Using strcmp()

#include <stdio.h>
#include <string.h>

int main()
{
    char a[100], b[100];

    printf("Enter a string to reverse\n");
    gets(a);

    //copying the content of string a to b
    strcpy(b, a);

    //reversing string b
    strrev(b);

    //comparing the reverse string to the intial string using strcmp()
    if (strcmp(a, b) == 0)
    {
        printf("The string is a palindrome\n");
    }
    else
    {
        printf("The string is not a palindrome\n");
    }

    return 0;
}

//..........coded by ANANYA MAURYA

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post