Getting wrong output in palindrome program

I created a program for checking if a given array is a palindrome or not
The output is appearing as not a palindrome for all inputs.
CODE
#include<stdio.h>

#include<stdlib.h>
int main()
{
char a[100];
int i=0,j=0,k=0,f=0;
printf(“Hello! \n Enter a word or a number.”);
gets(a);
while(a[i]!=’\0’)
{
j++;
i++;
}
int m=j/2;
for(;f<j/2,j>j/2;f++,j–)
{
if(a[f]==a[j-1])
{
k++;
}
}
if(k==m)
printf(“Palindrome.”);
else
printf("\nNot a palindrome.");

return 0;

}

Please format your code - the forum software has mangled it and it is uncompilable! :slight_smile:

Edit:

One problem that immediately jumps out is this: j>j/2.

Yea thanks, the program is working now partially but it won’t work for when the array’s length is an odd integer…