title: collatz c code logical error
body: <pre><code>static void collatz(int i)
  {
      int x=0,a=0,res=0,count=0;
      int array[50];
      array[0]=i;
      while(array[count]!=0)
      {
          if(array[count]%2==0)
          {
              count++;
              array[count]=i/2;
          }
          else
          {
              count++;
              array[count]=3*array[count-1]-1;
          }
      }
  }
  int main()
  {
      int a;
      scanf("%d",&amp;a);
      collatz(a);
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>When I compile and run the code, I enter 8 as "a" and console crushes itself. I'm using dev c.
  Sorry for my awful english but I hope I'm clear enough.</p>