Insert Function
| 79 | |
| 80 | //Insert Function |
| 81 | void 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 |
| 107 | void Delete(struct array *arr,int index) |