title: checking if a array has numbers in it from 0 to length -1 in C
body: <p>I have got an assignment and i'll be glad if you can help me with one question
  in this assignment, i have a question that goes like this:</p>
  
  <p><strong>write a function that receives an array and it's length.
  the purpose of the function is to check if the array has all numbers from 0 to length-1, if it does the function will return 1 or 0 otherwise.The function can go through the array only one.
  you cant sort the array or use a counting array in the function</strong></p>
  
  <p>i wrote the function that calculate the sum and the product of the array's values and indexes</p>
  
  <pre><code>int All_Num_Check(int *arr, int n)
  {
   int i, index_sum = 0, arr_sum = 0, index_multi = 1, arr_multi = 1;
  
   for (i = 0; i &lt; n; i++)
    {
      if (i != 0)
         index_multi *= i;
      if (arr[i] != 0)
         arr_multi *= arr[i];
  
      index_sum += i;
      arr_sum += arr[i];
    }
  
   if ((index_sum == arr_sum) &amp;&amp; (index_multi == arr_multi))
      return 1;
  
   return 0;
  }
  </code></pre>
  
  <p>i.e: length = 5, arr={0,3,4,2,1} - that's a proper array
  length = 5 , arr={0,3,3,4,2} - that's not proper array</p>
  
  <p>unfortunately, this function doesnt work properly in all different cases of number variations.
  i.e: length = 5 , {1,2,2,2,3}</p>
  
  <p>thank you your help.</p>