-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_array_sort.c
More file actions
44 lines (40 loc) · 784 Bytes
/
Copy path2_array_sort.c
File metadata and controls
44 lines (40 loc) · 784 Bytes
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
#include<stdio.h>
#include<conio.h>
void main()
{
int A[10],B[10],a,b,i;
//array 1
printf("No of the terms in Array 1 : ");
scanf("%d",&a);
printf(" Enter the elements of array 1 :\n");
for (i=0;i<a;i++)
{
scanf("%d",&B[i]);
}
//array 2
printf("No of the terms in Array 2 : ");
scanf("%d",&b);
printf(" Enter the elements of array 2 :\n");
for (i=0;i<b;i++)
{
scanf("%d",&B[i]);
}
// init merged array
int C[a+b];
int j;
// adding arrays
for ( i=0;i<a;i++)
{
C[i]= B[i];
}
for (i=0,j=a;j<(a+b) && i<b; i++,j++)
{
C[j]=B[i];
}
// merged array
printf("merged array\n");
for(i=0;i<(a+b))
{
printf("%d \t",C[i]);
}
}