C program To Check Whether given String is a Pallindrom Or Not
#include <stdio.h>
#include<conio.h>
void main()
{
char str[50];
int len=0,i=0,j,flag=1;
clrscr();
printf("Enter a string: ");
gets(str);
while(str[i++]!='\0')
len++;
for(i=0,j=(len-1);i<len/2;i++,j--)
{
if(str[j]!=str[i])
{
flag=0;
break;
}
}
if(flag==1)
printf("String is a palindrome");
else
printf("String is not a palindrome");
getch();
}
Loading...
|
Comments :
Post a Comment