All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Wednesday 26 February 2014

Merging a Array Before another Array

//Merging a Array Before another Array
#include<iostream.h>
#include<conio.h>
main()
{
 int a[50],b[50];
 int m,n,i;
 cout<<"Enter size of array A & B";
 cin>>m>>n;
 cout<<"Enter Elements of A";
 for(i=0;i<m;i++)
cin>>a[i];
 cout<<"Enter elements of B";
 for(i=0;i<n;i++)
cin>>b[i];

 for(i=m+n;i>=n;i--)
a[i]=a[i-n];
 for(i=0;i<n;i++)
a[i]=b[i];

 for(i=0;i<m+n;i++)
cout<<a[i]<<" ";
 getch();
 }

No comments:

Post a Comment