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

Explain what is #line used for?

1075


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

1162


What is the use of a semicolon (;) at the end of every program statement?

1518


explain how do you use macro?

1166


Explain what are global variables and explain how do you declare them?

1175


Is this program statement valid? INT = 10.50;

1167


Tell me the use of bit field in c language?

1072


Which header file is essential for using strcmp function?

1489


Can an array be an Ivalue?

1102


What is an auto keyword in c?

1101


Is return a keyword in c?

1093


What will be the outcome of the following conditional statement if the value of variable s is 10?

1301


What does %2f mean in c?

1229


Why pointers are used in c?

1018


What are operators in c?

1031