/* this program merges 2 arrays, the first has 2 elements and the second array has 3. I have initialised the arrays with values so that you can run the code and see the output. This can of course be generalised to arrays of any size which are read from a file or from the keyboard. */ #include <stdio.h> #define M 2 #define N 3 main() { int i=0,j=0,k=0; int a[M] = {2,3}, b[N]={4,5,6}, c[M+N]; while (i<M && j<N) if( a[i] < b[j] ) c[k++] = a[i++]; else c[k++] = b[j++]; while( i<M ) c[k++] = a[i++]; while ( j<N ) c[k++]=b[j++]; for (i=0;i<N+M;i++) printf("%d\n", c[i]); }