title: Delete every nth element of an array in C
body: <p>How can I delete every nth element of an array? <br>
  For exp: i have and array <code>a[]={2,12,4,5,67,33,24,45,6,1};</code> <br>
  and i want to delete every 3rd element so that resultant array is <code>a[]={2,12,5,67,24,45,1};</code><br>
  I know how to delete one element at one place but i can't find a way to delete the element on every 3rd place.
  <br><b>So i tried something like this:</b></p>
  
  <pre><code>int n,i;
  double *a;  
  printf("Enter number of elements: ");
  scanf_s("%d",&amp;n);
  
  a = (double*)malloc(100*sizeof(n));
  printf("Enter the elements: ");
  for( i=0;i&lt;n;i++) {
      scanf_s("%d",&amp;a[i]);
  
  }
  
  for( i=0;i&lt;n;i++) {
      printf("%d ",a[i]);
  
  }
  
  for(i=0;i&lt;n;i++){
      for ( i = 3 - 1 ; i &lt; n - 1 ; i++ ){
           a[i] = a[i+1];
      }
  }
  
    printf("\nResultant array is\n");
  
    for( i = 0 ; i &lt; n - 1 ; i++ )
       printf("%d\n", a[i]);
  </code></pre>
  
  <p>and there isn't any particular way that i need to do this, it can be in the same array or in a new array.</p>