-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10.c
39 lines (31 loc) · 776 Bytes
/
10.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
void display(int arr[], int n){
for(int i = 0; i< n; i++){
printf("%d ",arr[i]);
}
printf("\n");
// printf("\n");// printf("\n");// printf("\n");// printf("\n");// printf("\n");// printf("\n");
}
int indInsertion(int arr[],int size,int element, int capacity, int index){
if(size>capacity){
return -1;
}
int n;
for(int i = size-1;i>=index;i--){
//Swap
arr[i+1] = arr[i];
n = i;
}
arr[index] = element;
return 1;
}
int main()
{
int arr[100] = {1,2,6,7,8};
int size = 4,element = 45,index = 3;
display(arr,size);
indInsertion(arr, size, element, 100, index);
size++;
display(arr,size);
return 0;
}