Check if a string is palindrome.
#include <stdio.h>
#include <stdlib.h>
int palindrome(char str[]);
int main()
{
char str[] ="abcba";
printf("%c\n",str[5]);
if(palindrome(str)){
printf("is palindrome.");
}else{
printf("is not palindrome.");
}
return 0;
}
int palindrome(char str[]){
int i = 0, j = 0;
while(str[j+1] != '\0'){
j++;
}
while(i <= j){
if(str[i] != str[j]){
return 0;
}
j--;
i++;
}
return 1;
}