The way of combining two arrays into a single array is known as Array merging.
In this program, we are going to merge the content of two arrays into a single array.
#include <stdio.h>
int main()
{
int a[5]={1,3,5,7,9};
int b[5]={2,4,6,8,10};
int c[10];
int i,j;
for(i=0,j=0;i<10;i+=2,j++)
{
c[i] = a[j];
c[i+1] = b[j];
}
printf("Merged Array : \n");
for(i=0;i<10;i++)
{
printf("%d ",c[i]);
}
return 0;
}
OUTPUT:
Merged Array :
1 2 3 4 5 6 7 8 9 10
Array programs
- Sequence filter in array in C
- Array Search (Linear search)
- Array Merging
- Array Sorting
- C program to take marks and show percentage accordingly.
- C program to take user input to an array and show its content.
- C program to search an element in the array using a user – defined function.
- C program to search an element in the array using bsearch() function.
- C program to sort an array using qsort() functions.
- Recursive binary search in C.
Trending