C/C++ Program for Union of Two Arrays

Here you will get C/C++ program to find union of two arrays.

For example:

First array: {1, 3, 7, 9}

Second array: {1, 4, 6}

Union: {1, 3, 4, 7, 6, 9}

 

C/C++ Program for Union of Two Arrays

Union of Two Sorted Arrays

If two arrays are sorted then their union can be found in following way.

C Program

 

Output

Enter size of first array:4
Enter elements of first array in ascending order:
1 2 3 5

Enter size of second array:5
Enter elements of second array in ascending order:
1 3 5 7 9

Union of two arrays is:
1 2 3 5 7 9

 

C++ Program

 

Union of Two Unsorted Arrays

If two arrays are unsorted then their union can be found in following way.

C Program

 

Output

Enter size of first array:3
Enter elements of first array:
1 3 5

Enter size of second array:4
Enter elements of second array:
1 2 3 6

Union of two arrays is:
1 3 5 2 6

 

C++ Program

One thought on “C/C++ Program for Union of Two Arrays

  1. Gunther

    I’m sorry sir but sometimes can you puta comment on your program, it really helps if you put some code thanks. And followed you and added (y)

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *