C program for palindrome
<p>I'm still a beginner coder, and I am having trouble writing a program to check whether a string is a palindrome or not using only <code>&lt;stdio.h&gt;</code> and <code>&lt;stdlib.h&gt;</code> libraries.</p>

<p>The string can take at most 30 characters. We must assume that the string can take digits, punctuation characters, and letters. Also, assume there are no spaces in the string. Must differentiate between uppercase and lowercase characters. So "madam" would be a palindrome, but "MaDam" would not be a palindrome. The string ends with a null terminator.
Hi, so when I compile with gcc -Wall. I get these errors. Can someone please explain how I can fix these errors? Thank you for your time.</p>

<pre><code>s_palindrome.c:24:15: warning: variable 'length' is used uninitialized whenever
  'for' loop exits because its condition is false
  [-Wsometimes-uninitialized]
for (a=0; **a&lt;30**; a++){

is_palindrome.c:36:18: note: uninitialized use occurs here
for (a=0; **a&lt;(length/2)**; a++){

is_palindrome.c:24:15: note: remove the condition if it is always true
for (a=0; **a&lt;30**; a++){

is_palindrome.c:12:18: note: initialize the variable 'length' to silence this
  warning
**int a, length;**= 0
</code></pre>

<p>Code</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
int main (){
char string [30];
int a, l;
int p=1;

printf("Enter a string to test: \n");
scanf("%s", string);

for (a=0; a&lt;30; a++){
    if (string[a]=='\0'){
        l=a;
        break;
    }
}

for (a=0; a&lt;l/2; a++){
    if (string[a]!=string[l-1-a]){
        p=0;
    }
}

if (p){
    printf("%s is a palindrome\n", string);
}
else {
    printf("%s is not a palindrome\n", string);
}

return 0;
}
</code></pre>