-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge array.txt
More file actions
37 lines (36 loc) · 1.34 KB
/
merge array.txt
File metadata and controls
37 lines (36 loc) · 1.34 KB
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
#include <stdio.h> //NAME- KINGSUK BASAK ; Roll - CSE2019/027;
#include <stdlib.h>
void main()
{
int size1, size2, pos, ar1[100], ar2[100], merge[200];
do
{
printf("Enter size of first array less than 100 : "); //taking first array size less than 100.
scanf("%d", &size1);
printf("Enter size of second array less than 100 : "); //taking second array size less than 100.
scanf("%d", &size2);
} while (size1 > 100 && size2 > 100);
for (int i = 0; i < size1; i++) //creating first array of random elements.
ar1[i] = rand();
for (int i = 0; i < size2; i++) //creating second array of random elements.
ar2[i] = rand();
for (int i = 0; i < size1; i++) //coping first array to merge array.
{
merge[i] = ar1[i];
}
pos = size1;
for (int i = 0; i < size2; i++) //adding second array to merge array.
{
merge[pos] = ar2[i];
pos++;
}
printf("\nFirst array : ");
for (int i = 0; i < size1; i++) //printing first array.
printf("%d , ", ar1[i]);
printf("\nSecond array : ");
for (int i = 0; i < size2; i++) //printing second array.
printf("%d , ", ar2[i]);
printf("\nMerge array : ");
for (int i = 0; i < size1 + size2; i++) //printing merge array.
printf("%d , ", merge[i]);
}