Just wrote a program to check if a string is Palindrome. If that's true, return 1. Else, return 0. How can I improve it?
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int palindrome(char *s)
{
int i = 0, length = strlen(s) - 1, n = length;
int boolean = 0;
for (; i <= length && n >= 0; i++, n--) {
if (toupper(s[i]) == toupper(s[n]))
boolean = 1;
else
boolean = 0;
}
return boolean;
}
int main(void)
{
char string[] = "Racecar";
printf("%d", palindrome(string));
return 0;
}