-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharray insert.cpp
55 lines (42 loc) · 959 Bytes
/
array insert.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
int main()
{
int a[100],i,pos,size,item;
printf("enter size of array : ");
scanf("%d",&size);
printf("enter array elements: ");
for(i=0;i<size;i++){
scanf("%d",&a[i]);
}
printf("enter position that u want to inter: ");
scanf("%d",&pos);
printf("enter item that u want to insert: ");
scanf("%d",&item);
for(i=size;i>=pos;i--){
a[i]=a[i-1];
}
a[pos]=item;
size++;
printf("final array\n ");
for(i=0;i<size;i++){
printf("%d",a[i]);
}
int loop, smallest;
smallest = a[0];
for(loop = 1; loop < size; loop++) {
if( smallest > a[loop] )
smallest = a[loop];
}
printf("\t\tSmallest element of array is %d\n", smallest);
int large;
i=0;
large = a[i];
while(i<size)
{
if(large<a[i])
large = a[i];
i++;
}
printf("\nLargest Number = %d", large);
return 0;
}