MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / Insert

Function Insert

Arrays/31_Menu_for_Array.c:81–104  ·  view source on GitHub ↗

Insert Function

Source from the content-addressed store, hash-verified

79
80//Insert Function
81void Insert(struct array *arr,int index,int x)
82{
83 int i;
84 if(arr->length<arr->size)
85 {
86 if(index>=0 && index<=arr->length)
87 {
88 for(i=arr->length;i>index;i--)
89 {
90 arr->A[i]=arr->A[i-1];
91 }
92 arr->A[index]=x;
93 arr->length++;
94 }
95 else
96 {
97 printf("You cannot insert the value due to the invalid index. \n");
98 }
99 }
100 else
101 {
102 printf("The size is not sufficient to insert the element in the array.\n");
103 }
104}
105
106//Delete Function
107void Delete(struct array *arr,int index)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected