source file name: palindr.C
#include <string.h>
#include<stdio.h>
int main()
{
char str[20];
int i, len;
int op = 0;
//clrscr();
printf("Enter a string:");
scanf("%s", str);
len = strlen(str);
for(i=0;i < len ;i++)
{
if(str[i] != str[len-i-1])
{
op = 1;
break;
}
}
if (op)
printf("%s is not a palindrome", str);
else
printf("%s is a palindrome", str);
//getch();
return 0;
}
output:
0 Comments
Post a Comment