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


Please Help Members By Posting Answers For Below Questions

Is it cc or c in a letter?

565


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2241


what is the basis for selection of arrays or pointers as data structure in a program

3788


What are near, far and huge pointers?

648


What is file in c preprocessor?

653






What are the differences between Structures and Arrays?

609


What is the size of a union variable?

598


Explain what is page thrashing?

609


How can a number be converted to a string?

605


What is a global variable in c?

587


What is a program flowchart and explain how does it help in writing a program?

674


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1461


What is pointers in c with example?

583


What language is c written?

577


What are multibyte characters?

642