476 Programming and Data Structures
ends. In this case, due to lack of space, insertion operation is impossible.
The position number where an element is to be inserted and the element are prompted by the
program. After the user enters these values, using while loop, the position of the first vacant location
is determined. From user specified, position number, next all successive elements are shifted one
memory location towards down side of array. Due to this shifting, space is generated and the entered
element is placed at that location.
14.8 DELETION
Like insertion, deletion of an element can be done from the list. In deletion, the elements are moved
upwards by one position.
14.5 Write a program to create a list of integec elements Delete the specified element from
the list.
ft inaluda <at<Uo.,2s>
P include <conio.h>
| Inaludt <proc«*8.h>
u i n t)
{
int nutt{8]{<)},j,0,p,n;
clrscr();
printf ("\n Inter elements ( 0 to exit ) : );
lor (j»0;j<8;j++)
{
■canf ("%da,&num[j]);
if < 0)
break?
}
printf (B\n Enter am element to remove : *);
■canf ("%d*,in);
while (nvun[k] 1 »n)
k*+?
for (j-k;j<7;j++)
nuafj]»num[j+1];
num[j] »0»
for (j<8;j++)
printf ( %d ", num[j]);
OUTPUT:
Enter elements ( 0 to exit): 58942347

Get Programming and Data Structures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.