1.write a program to merge the arrays
2.write efficient code for extracting unique elements from a
sorted list of array?
Answer Posted / whyname
To merge to arrays ( Note the question has no mention of
sorting the array elements, hence the program below just
merges two arrays)
int array1[5] = {1,2,3,4,5};
int array2[7] = {6,7,8,9,10,11,12};
int i;
int merged[(sizeof(array1)+ sizeof(array2))/sizeof(int)];
memcpy( merged, array1, sizeof(array1));
memcpy( (merged+5), array2, sizeof(array2));
for(i=0;i<(sizeof(merged)/sizeof(int)); i++)
{
printf("%d\n",merged[i]);
}
Is This Answer Correct ? | 20 Yes | 15 No |
Post New Answer View All Answers
What is #include stdio h?
Explain how does free() know explain how much memory to release?
to find the closest pair
What is calloc malloc realloc in c?
Why c language?
Lists the benefits of c programming language?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Does sprintf put null character?
How can I read data from data files with particular formats?
What are the standard predefined macros?
What is the difference between union and structure in c?
Why c is called a mid level programming language?
What is a header file?
What is ambagious result in C? explain with an example.
What is use of bit field?