Program to Check If string is Palindrome (in C) 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 &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;

int palindrome(char *s)
{
    int i = 0, length = strlen(s) - 1, n = length;
    int boolean = 0;

    for (; i &lt;= length &amp;&amp; n &gt;= 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;
}
Bug
Given the input &quot;racebar&quot;, the function returns true.  The problem is that your boolean variable is reset after each character pair, so you are only really testing the first character with the last.  I would do the following:

Get rid of the boolean variable and return false on the first mismatch.
Fix the loop iteration to only iterate through half the string instead of the whole string.
Mark the input parameter as const, since you do not modify the input string.  This allows your function to accept both const strings and non-const string as arguments.
In C99, you can declare loop variables inside the loop itself, which helps to reduce the scope of these variables to only where they are used.

Here is a rewrite showing all of the above:
int palindrome(const char *s)
{
    for (int i = 0, n = strlen(s) - 1; i &lt; n; i++, n--) {
        if (toupper(s[i]) != toupper(s[n]))
            return 0;
    }

    return 1;
}