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;
}