delete element in array using function

#include<stdio.h>

int deletearr(int n)
{
    int pos, num , a[1000] , i , j, k;

    num =n;
    printf("Enter the %d elements :",num);
    for(i=0;i<num;i++)
    {
        scanf("%d", &a[i]);
    }
    printf(" Enter the position of the array to be deleted :\t");
    scanf("%d",&pos);

    k=num+1;

    if(pos>=k)
    {
        printf("\n It Is Not Possible To Delete The Array");
    }
    else
    {
        for(i = pos-1; i<num-1; i++)
            a[i] = a[i+1];

        printf(" The Final Array is : \t ");

        for(i=0 ; i<num-1 ; i++)
        {
            printf("%d\t",a[i]);
        }

    }

    return 0;
}



int main()
{
    int n, x ;

    printf(" Enter the number of elements : ");
    scanf("%d",&n);

    x=deletearr(n);

    return 0;
}




OUTPUT : - 




For Other Programs Visit The WebSite:-   https://www.techapurba.com/
                                                                                                                      
Follow Me On Social Media :-
INSTA photography page :- https://www.instagram.com/photo_mania_hub/

Insta photography link :- https://www.instagram.com/photo_mania_hub/
For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/

Post a Comment

0 Comments