Skip to content

Commit e210c4c

Browse files
delete from array
1 parent 257e1d8 commit e210c4c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

4. Array ADT/delete_from_array.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ void Display(struct Array arr)
1717
}
1818
}
1919

20+
int Delete(struct Array *arr,int index)
21+
{
22+
int x=0;
23+
int i;
24+
if(index>=0 && index<arr->length)
25+
{
26+
x=arr->A[index];
27+
for(i=index;i<arr->length-1;i++)
28+
{
29+
arr->A[i]=arr->A[i+1];
30+
}
31+
arr->length--;
32+
return x;
33+
}
34+
return 0;
35+
}
36+
2037
int main()
2138
{
2239
return 0;

0 commit comments

Comments
 (0)