title: Finding pairs in an array
body: <p>So what I am trying to do is make a code to find pair of numbers in an array. This code below works perfectly when there is a single pair of numbers.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  main()
  {
      int arr[10], i, j, pairs = 0;
      int n;
      scanf(&quot;%d&quot;, &amp;n);
      for (i = 0; i &lt; n; i++)
      {
          scanf(&quot;%d&quot;, &amp;arr[i]);
      }
      for (i = 0; i &lt; n; i++)
      {
          for (j = i + 1; j &lt; n; j++)
          {
              if (arr[i] == arr[j])
              {
                  pairs++;
              }
          }
      }
      printf(&quot;%d&quot;, pairs);
  }
  </code></pre>
  <p>I want to make it so that it works when there are 3 same elements.
  For example, <code>arr[5] = 1, 1, 1, 2, 2</code>
  it should return 2 pairs (<code>1,1</code> and <code>2,2</code> with an extra 1 left out) but it returns 4 pairs instead with my code!</p>