C program to delete an element in an array

in #programming7 years ago

Deleting an element refers to the deletion of a single element at particular location in array. We will try to delete this element using c program.

             

Program:


#include<stdio.h>

int main()

{

    int i,p,n,a[20],c[20];

    printf("Enter the value of n:\n");

    scanf("%d",&n);

    printf("Enter the value in 1 :\n");

    for(i=0;i<=n;i++)

    {

        scanf("%d",&a[i]);

    }

    printf("Enter the value of p:\n");

    scanf("%d",&p);

    for(i=p;i<=n;i++)

    {

        a[i]=a[i+1];

    }

     for(i=0;i<=n-1;i++)

    { printf("%d",a[i]);

}

}