title: Finding duplicates with pointers
body: <pre><code>#include &lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int main()
  {
      int *num=malloc(sizeof(int)*10);
      int n,dup=0;
      printf("Enter number of elements");
      scanf("%d",&amp;n);
      printf("Enter numbers");
      for(int i=0;i&lt;n;i++)
      {
              scanf("%d",num+i);
  
      }
  
      for(int i=0;i&lt;n;i++)
      {
          for(int j=1;j&lt;n;j++)
          {
              if(*(num+i)==*(num+j))
              {
                      dup++;
              }
  
           }
           }
  
      printf("%d",dup);
      free(num);
  
      return 0;
  }
  </code></pre>
  
  <p>I'm trying to find the number of times an element is repeated,using pointers.But I'm not getting the right output.What's wrong with this code?
  Edit: for inputs 1,2,3 I'm getting an output of 2.</p>