Program in C to delete element in an array

#include<stdio.h>
#include<conio.h>

void main()
{
            int num[20],j,p,n,s;
            clrscr();
            printf(“enter the number of elements\n”);
            scanf(“%d”,&n);
            printf(“enter the elements of array\n”);
            for(j=0;j<n;j++)
                        scanf(“%d”,&num[j]);
            printf(“enter the position to delete\n”);
            scanf(“%d”,&p);
            p--;
            for(j=p;j<n;j++)
                        num[j]=num[j+1];
            for(j=0;j<n-1;j++)
                        printf(“%d”,num[j]);
            getch();
}



Post a Comment