forked from ravikartar/hacktober2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge array.cpp
More file actions
30 lines (30 loc) · 735 Bytes
/
merge array.cpp
File metadata and controls
30 lines (30 loc) · 735 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
#include<iostream>
using namespace std;
int main()
{
int arrOne[50], arrTwo[50], arrMerge[100];
int sizeOne, sizeTwo, i, k;
cout<<"Enter the Size for First Array: ";
cin>>sizeOne;
cout<<"Enter "<<sizeOne<<" Elements for First Array: ";
for(i=0; i<sizeOne; i++)
{
cin>>arrOne[i];
arrMerge[i] = arrOne[i];
}
k = i;
cout<<"\nEnter the Size for Second Array: ";
cin>>sizeTwo;
cout<<"Enter "<<sizeTwo<<" Elements for Second Array: ";
for(i=0; i<sizeTwo; i++)
{
cin>>arrTwo[i];
arrMerge[k] = arrTwo[i];
k++;
}
cout<<"\nThe New Array (Merged Array):\n";
for(i=0; i<k; i++)
cout<<arrMerge[i]<<" ";
cout<<endl;
return 0;
}