title: Finding duplicate values in array in c
body: <p>I am trying to find the duplicate values in an array. When a number is duplicated once like <code>(25,25)</code> program correctly prints 25 once but when a number duplicated twice like <code>(12,12,12)</code> program prints 12 three times while it should print it once.</p>
  
  <pre><code> #include&lt;stdio.h&gt;
   int main()
  {
      int numbers[15]={1,1,2,2,2,3,4,5,6,6,7,7,7,8,9},i,j;
      for(i=0;i&lt;15;i++)
      {
          for(j=i;j&lt;14;j++)
          {
              if(numbers[i]==numbers[j+1])
              {
                  printf("Number %d has duplicate values\n",numbers[i]);
              }
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Number 1 has duplicate values
  Number 2 has duplicate values
  Number 2 has duplicate values
  Number 2 has duplicate values
  Number 6 has duplicate values
  Number 7 has duplicate values
  Number 7 has duplicate values
  Number 7 has duplicate values
  </code></pre>
  
  <p>The arrays cannot be assumed to be ordered so the program should work even with <code>{1,2,1,2,3,4,2,5,6,6,7,7,7,8,9}</code>.</p>