Turn Desktop View Off
by Dinesh Thakur Category: Array
#include <Stdio.h>

#include <conio.h>
main()
{
      int arr1 [10], arr2 [10], arr3 [20];
      int i, n1, n2, m, index=0;
      clrscr();
      printf("\n Enter the number of elements in array 1: ");
      scanf("%d", &n1);
      printf("\n\n Enter the Elements of the first array");
      printf("\n ****************************");
  for(i=0;i<n1;i++)
  {
     scanf ("%d",&arr1[i]);
  }
     printf("\n Enter the number of elements in array 2: ");
     scanf ("%d", &n2 );
     printf("\n\n Enter the Elements of the second array");
     printf("\n ****************************");
  for(i=0;i<n2;i++)
  {
     scanf ("%d", &arr2[i]);
     m = n1+n2;
  }
     for(i=0;i<n1;i++)
     {
        arr3[index]=arr1[i];
        index++;
     }
          for(i=0;i<n2;i++)
          {
             arr3[index]=arr2[i];
             index++;
          }
             printf ("\n\n The merged array is");
             printf ("\n ******************** " );
   for(i=0;i<m;i++)
   {
       printf("\t\n Arr[%d] = %d", i, arr3[i]);
   }
       getch();
       return 0;
}

merge two unsorted arrays 



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles