C Program to delete an element from array by element
Simple C program to delete an element from array by element: To delete an element from array, first we will find the position of that element and we will shift element.
/* C program to delete array from array by position */ #include<stdio.h> int main() { int arr[100],n,i,position; printf("Enter a number for elements: "); scanf("%d",&n); printf("Enter %d elements:\n",n); for(i=0;i<n;i++) { scanf("%d",&arr[i]); } printf("Enter position from which you want to delete: "); scanf("%d",&position); for(i=position-1;i<n-1;i++) { arr[i]=arr[i+1]; } printf("Array: \n"); for(i=0;i<n-1;i++) { printf("%d ",arr[i]); } return 0; } /* End of the program */