title: Make a string Palindrome in C
body: <p>James found a love letter his friend Harry has written for his girlfriend. James is a prankster, so he decides to meddle with the letter. He changes all the words in the letter into palindromes.</p>
  
  <p>To do this, he follows 2 rules:</p>
  
  <p>(a) He can reduce the value of a letter, e.g. he can change 'd' to 'c', but he cannot change 'c' to 'd'. 
  (b) In order to form a palindrome, if he has to repeatedly reduce the value of a letter, he can do it until the letter becomes 'a'. Once a letter has been changed to 'a', it can no longer be changed.</p>
  
  <p>Each reduction in the value of any letter is counted as a single operation. Find the minimum number of operations required to convert a given string into a palindrome. </p>
  
  <p>Input Format 
  The first line contains an integer T, i.e., the number of test cases. 
  The next T lines will contain a string each. The strings do not contain any spaces.</p>
  
  <p>Output Format 
  A single line containing the number of minimum operations corresponding to each test case.</p>
  
  <p>Constraints 
  1 ≤ T ≤ 10
  1 ≤ length of string ≤ 104 
  All characters are lower case English letters.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main() {
  
      /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
      int count;
      int result;
      int i,j;
  
      scanf("%d",&amp;count);
  
      for (i = 0 ; i &lt; count ; i++){
  
          result = 0;
  
          char * string;
          scanf("%ms",&amp;string);
  
          int k = (int)strlen(string);
  
          printf("Length: %d\n",k);
  
          int l = k/2;
  
          printf("L is: %d\n",l);
  
          for ( j = 0 ; j &lt; l ; j++){
  
              printf("first char is is: %c\n",string[j]);
              printf("Second char is is: %c\n",string[k-j-1]);
              printf("Current loop count: %d\n",j);
  
              if ( string[j] != string [k-j] ){
  
                  int g = (int)(string[j] - string[k-j-1]);
                  if ( g &gt; 0){
                      result += g;
                  }
                  else{
                      result -= g;
                  }
  
              }
              else;
  
          }
  
          printf("%d\n",result);
  
      }
      return 0;
  }
  </code></pre>
  
  <p>Sample Input #00</p>
  
  <pre><code>4
  abc
  abcba
  abcd
  cba
  </code></pre>
  
  <p>Sample Output #00</p>
  
  <pre><code>2
  0
  4
  2
  </code></pre>
  
  <p>Explanation</p>
  
  <p>For the first test case, abc -> abb -> aba.
  For the second test case, abcba is already palindromic string.
  For the third test case, abcd -> abcc -> abcb -> abca = abca -> abba.
  For the fourth test case, cba -> bba -> aba.</p>
  
  <p>The above stated code is working for the given sample input, but it is not the correct one according to hacckerrank. Can someone point out the error please?</p>