-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmergeunsort.c
42 lines (38 loc) · 880 Bytes
/
mergeunsort.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
40
41
42
//Merge two unsorted arrays
#include<stdio.h>
#define MAX 10
main()
{
int arr1[MAX],arr2[MAX],arr[MAX];
int num,pos,n1,n2,n,index;
printf("Enter the number of elements of array 1: ");
scanf("%d",&n1);
printf("Enter the elements of array1: ");
for(int i=0;i<n1;i++)
{
scanf("%d",&arr1[i]);
}
printf("Enter the number of elements of array 2: ");
scanf("%d",&n2);
printf("Enter the elements of array2: ");
for(int i=0;i<n2;i++)
{
scanf("%d",&arr2[i]);
}
for(int i=0;i<n1;i++)
{
arr[i]=arr1[i];
index++;
}
for(int j=0;j<n2;j++)
{
arr[index]=arr2[j];
index++;
}
n=n1+n2;
printf("The elements of the array are: ");
for(int k=0;k<n;k++)
{
printf("%d\t",arr[k]);
}
}