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 union and structure in c?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
Why & is used in c?
What is pragma c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What does s c mean in text?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
What does & mean in scanf?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
When do we get logical errors?
What is structure padding and packing in c?
What is time complexity c?
What is hash table in c?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?