C Program To Delete Element From Array At Desired Or Specific Position

Hello reader! Do you know one thing? Using this article, We can execute the script of “C Program To Delete Element From Array At Desired Or Specific Position”. Let’s start an article to see the possibilities below.

C Program To Delete Element From Array At Desired Or Specific Position

C Program To Delete Element From Array At Desired Or Specific Position

Program Code

#include<stdio.h>
int main()
{
 //Ghanendra Yadav
  int i,arr[50],pos,len;

  printf("Enter no. of elements for the array:n");
  scanf("%d",&len);

  printf("Enter %d elements for the array:n",len);
  for(i=0;i<len;i++)
            scanf("%d",&arr[i]);

  printf("Enter position of the element to delete:n");
  scanf("%d",&pos);

  i = pos-1;

  while(i<len - 1)
  {
            arr[i]=arr[i+1];
            i++;
  }
  len--;
  printf("Array after deleting elementn");

  for(i=0;i<len;i++)
            printf(" %d",arr[i]);

  return 0;
}

Final Words

I hope this article helps you to know about “Delete Element From Array At Desired Or Specific Position Using C Program”. If you face any issues please let me know via the comment section. Share this article with other C/C++ developers via social networks.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment