Write a program to check that the input string is a palindrome or not

Spread the love

/******* Program **********/

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

main()
{
        char str[20];
        int i,j,len,cnt;
        cnt = 0;

        printf(“Enter string to test :”);
        scanf(“%s”,str);

        len = strlen(str);

        for(i=0,j=len-1;i<j;i++,j–)
        {
                if(str[i] != str[j])
                cnt++;
        }

        if(cnt == 0)
        printf(“Given string is Palindrome ..n”);
        else
        printf(“Given string is not Palindrome..n”);
}


/********* OUTPUT *************/


Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply