title: Variable is taking Garbage value in spite of initializing it
body: <p>I created a function to "Reverse a linked list", for that I initialized an array of pointers of size 3. to implement the code I have to constantly re assign the pointers and for that I created two variables <code>a</code> and <code>b</code>.</p>
  
  <p>I initialized both the variables but upon printing them for checking if they have the correct value, the second variable is taking up garbage value.</p>
  
  <p>I already tried by directly working with the iterator <code>i</code> instead of variables but no luck.</p>
  
  <pre><code>int reverseData(struct student **head) {
  
      struct student *arr[2];
  
      int i=1,a=2,c=(a+1)%3;  // THIS IS INITIALIZATION OF 'C'
  
      if(*head==NULL){
          printf("UNDERFLOW\n\n");
          return 0;
      }
  
      arr[2]=*head;
      arr[1]=arr[2]-&gt;next;
      printf("\nexecuted\n");
  
      if(arr[2]-&gt;next!=NULL)
          arr[0]=arr[1]-&gt;next;
  
      arr[2]-&gt;next=NULL;
  
      while(1) {
  
          printf("\nexecuted while\n");
          printf("\n%d\n", a);
          printf("%d\n", c);            //THIS IS THE FIRST TIME PRINT OF 'C'    
  
          if(arr[(i+2)%3]-&gt;next==NULL)
              break;
  
          arr[i]-&gt;next=arr[a];
          arr[a]=arr[c]-&gt;next;
  
          i=((i&gt;0)?(i-1):2);
          a=(i+1)%3;
          c=(a+1)%3;
  
      }
      printf("\nwhile exit\n");
  
  
  
  
      arr[i]-&gt;next=arr[a];
      printf("yuhu");
      arr[c]-&gt;next=arr[i];
  
      *head= arr[c];
      printf("done dana done");
      return 0;
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre class="lang-none prettyprint-override"><code>1 c     // THIS IS THE LINKED LIST HAVING A NUMBER AND A CHAR[20]
  1 b
  1 a
  
  1. Insert
  2. Delete
  3. Reverse
  4. Exit
  3
  executed
  
  executed while
  
  2
  6819248      // THIS IS THE VALUE OF C PRINTED
  
  while exit
  yuhu
  </code></pre>