Thursday, July 21, 2011

Program to check for palindrome

/*Serial No.101     [swami77.cpp]*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,len,flag;
char str[10],rev[10];
clrscr();
printf("Enter the string==>");
scanf("%s",str);
len=strlen(str);
printf("\nLength of %s is ==>%d\n",str,len);
for(i=0;str[i]!='\0';i++)
    {
    if(str[i]!=str[len-1-i])
      {
      flag=3;
      break;
      }
    }
if(flag==3)
    printf("\nString is not polyndrom");
     else
    printf("\nString is polyndrom");
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...