diff --git a/Intersection_of_2_arrays.cpp b/Intersection_of_2_arrays.cpp new file mode 100644 index 000000000..e2c064e1b --- /dev/null +++ b/Intersection_of_2_arrays.cpp @@ -0,0 +1,30 @@ +#include +int main() +{ + int i,j,m,n; + cout <<"Enter size of array 1:"; + cin >> m; + cout <<"Enter size of array 2:"; + cin >> n; + int a[m]; + int b[n]; + cout <<"Enter elements of array 1:"; + for(i=0;i> a[i]; + for(i=0;i> b[i]; + i=0;j=0; + while((ib[j]) + j++; + else + { + cout << a[i++]<<" "; + j++; + } + } + return 0; +} diff --git a/Union_of_2_arrays.cpp b/Union_of_2_arrays.cpp new file mode 100644 index 000000000..4046e1ae8 --- /dev/null +++ b/Union_of_2_arrays.cpp @@ -0,0 +1,33 @@ +#include +int main() +{ + int m,n,i=0,j=0; + cout << "Enter size of both arrays:"; + cin >> m >> n; + int a[m]; + int b[n]; + cout << "Enter elements of array 1:"; + for(i=0;i>a[i]; + cout << "Enter elements of array 2:"; + for(i=0;i> b[i]; + i=0;j=0; + while((ib[j]) + cout << b[j++] <<" "; + else + { + cout << a[i++]; + j++; + } + } + while(i