C program to delete an element in an array

in #programming6 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]);

}

}



Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.031
BTC 63047.55
ETH 2690.45
USDT 1.00
SBD 2.54