Menu

Tuesday, 23 June 2015

Write a C Program to find wethe the given string is Palandrome or not



#include<stdio.h>
main()
{
    char str[10];
    int len,i,no,flag;
    printf("Enter a string: ");
    scanf("%s",str);
    len=strlen(str);
    no=len/2;
    i=0;
    while(i<=no)
    {
        if(str[i]==str[len-i-1])
        {
            flag = 1;
            i++;
            continue;
        }
        else
        {
            flag=0;
            break;
        }
    }
    if(flag)
    {
        printf("String is palindrome");
    }
    else
    {
        printf("String is not a palindrome");
    }
}

OUTPUT
Enter a string: ctc
String is Palindrome