Problem Statement: Merging and Sorting of character arrays
You are required to write a program that takes character values in two different arrays as input from user. After getting input, make a third array and merge both these array in third array. Output array must be sorted in ascending order.


Detailed Description:

1. Declare three character type arrays.
2. Use two arrays to take input from user.
o Take input as char type.
o Take 10 values in each array.

3. Merge both these input arrays.
o If an input character is in both arrays, then it should appear once in resulted array.
4. Store result in third array.
5. Sort resulted array in ascending order.
o Ascending order means string values starting from ‘a’ will come first, and then starting from ‘b’ and so on.
6. Display them after sorting

Sample Output
Enter values in first array: a h b c u v I j k e
Enter values in Second array: y u d f g k I w q a

Merged array: a y h u b d c f g v k I j w q e

Sorted Array in ascending order: a b c d e f g h I j k q u v w y

Take it step by step.

create this part first :

Enter values in first array: a h b c u v I j k e 
Enter values in Second array: y u d f g k I w q a

Then create this part :

Merged array: a y h u b d c f g v k I j w q e

And then sort it.

For the merge part, you function prototype could look like this :

void mergeArray(char * src1, int src1Size, char * src2, int src2Size, char * dest);

It assumes that dest has enough memory.

This article has been dead for over six months. Start a new discussion instead.