C Program to Delete an element from specified location in Array

This page has a C Program to delete an element from the specified location in Array. It is clear that, this C program will delete an element from the specified location from Array. For example: If we have entered 6 elements in an array as 35 78 64 43 12 46 and if we want to delete an element (43) from the array, then the program should ask the location (3) of the element (43) to be deleted from the array; Then the program will have to accept the the location (4) and then the element will be deleted from the array as 35 78 64 12 46. The below given C program will delete an element from Array. Kindly check out the program to delete an element from the Array. The questions to delete an element from Array can be asked as, 1). C Program to delete an element from the specified location from Array

2). C program to delete an element from an array

3). C Program to delete the specified element from an Array

4). C program to delete an element from specified location in array



Program to Insert an element in Array

#include<stdio.h>

int main(){

int array1[30];

int i, loc, n1, n2;

printf("

Enter no of elements to array : ");

scanf("%d", &n1);

printf("



Enter the Array elements one by one

");

for (i = 1; i<=n1; i++) {

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

}

printf("

Enter a location to be deleted :");

scanf("%d", &loc);

for (i = n1; i>loc; i--)

array1[i-1]=array1[i];

printf("

The Array elements are :

");

for (i = 1; i<=n1-1; i++)

printf("

%d", array1[i]);

return(0);

} Sample Output:

Enter no of elements to array : 6

Enter the Array elements one by one

57 34 67 23 56 38

Enter a location to be deleted :3

The Array elements are :

57

34

23

56

38

Related Popular Posts: