Merging Two One Dimensional Numeric Array
#include <iostream.h>
#include <conio.h>
void main()
{
int a[5], b[5], c[10], i, j;
clrscr();
cout << "Enter values for array 1 : ";
for(i=0; i<5; i++)
cin >> a[i];
cout << "Enter values fro array 2 : ";
for(i=0; i<5; i++)
cin >> b[i];
for(i=0,j=0; i<5; i++, j++)
c[j]=a[i];
for(i=0; i<5; i++, j++)
c[j]=b[i];
//display merged array
for(i=0; i<10; i++)
cout << c[i] << "\t";
getch();
}


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home