# String Palindrome Problem

My Own Logic:

```#include<stdio.h>
int main()
{

char str[200];
int i,j;
gets(str);
for(i=0;str[i]!='\0';i++);
for(j=0;j<i;j++)
{
if(str[0]==str[i-1]){
printf("Palindrome\n");
break;
}else{
printf("Not Palindrome\n");
break;
}

}
printf("%d\n",i);
printf("1st char = %c\n",str[0]);
printf("last char = %c\n",str[i-1]);

return 0;
}
```

Another logic:

```#include<stdio.h>
int main()
{

char str[200];
int i,j,flag=0,lngth;
gets(str);
for(i=0; str[i]!='\0'; i++);
lngth=i-1;
for(j=0; j<lngth/2; j++)
{
if(str[j]==str[lngth-j])
{
flag=1;
}
else
{
flag=0;
}
}
if(flag==1)
{
printf("Palindrome\n");

}
else
{
printf("Not Palindrome\n");

}

return 0;
}
```

Simple:

```#include<stdio.h>
int main()
{

char str[200];
int i,j,flag=0,lngth;
gets(str);
for(i=0; str[i]!='\0'; i++);
lngth=i-1;
for(j=0; j<lngth/2; j++)
{
if(str[j]==str[lngth-j])
{
printf("Palindrome\n");
break;
}
else
{
printf("Not Palindrome\n");
break;
}
}

return 0;
}```

another good logic:

```#include<stdio.h>
int main()
{
char str[20],rev[20];
int i,j,k,len;
gets(str);
for(i=0; str[i]!='\0'; i++);
len=i-1;
for(j=len,k=0; j>=0; j--,k++)
{
rev[j]=str[k];
}
for(i=0; i<len; i++)
{

if(rev[i]==str[i])
{
printf("Palindrome");
break;
}
else
{
printf("Not Palindrome");
break;
}
}

return 0;

}
```

It would be a great help, if you support by sharing :)
Author: zakilive