Deletion in array at particular position

Deletion in array at particular position:)

It is a process in which we delete any element of array list at particular position

example:

insert- 10,20,30,40,50
and delete the element of  third position(value=30 )
10
20
30
40
50

0              1              2              3              4


/*program for delete element in array*/
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>

void deletion( int a[],int size,int position)
{
    int i;
    printf("deleted element from list=%d", a[position-1]);
    for(i=position-1; i<size-1;i++)
    {
        a[i]=a[i+1];
    }
    size--;
    printf("all remaining element are=\n");
    for(i=0;i<size;i++)
    {
        printf("%d\n",a[i]);

    }

}
 void main()
 {
     int a[50], size, element, position, i;
     printf("enter the size of list==");
     scanf("%d",&size);
     printf("enter the value of list==\n");
     for(i=0;i<size;i++)
     {
         scanf("%d",&a[i]);
     }
     printf("inter the position for deletion==");
     scanf("%d",&position);

     deletion(a,size,position);
}

output










I hope this post is useful for you!
if you like my post plzzz flow my blog....

note:-
 for my previous post related data structure go to menu of website.







Comments

Popular posts from this blog

python pattern programming

Stack

What is function?What is function in python?