Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is union and structure in c?

1148


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

1117


Why & is used in c?

1117


What is pragma c?

1059


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.

2277


What does s c mean in text?

1053


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.

2212


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....

1916


What does & mean in scanf?

1042


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1029


When do we get logical errors?

1071


What is structure padding and packing in c?

1004


What is time complexity c?

940


What is hash table in c?

971


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2520