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 a substring in c?

1032


Can two or more operators such as and be combined in a single line of program code?

1361


What is hungarian notation? Is it worthwhile?

1218


Why is structure important for a child?

1097


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

1243


What is main () in c?

1066


What is the difference between union and anonymous union?

1302


writ a program to compare using strcmp VIVA and viva with its output.

2013


Tell me is null always defined as 0(zero)?

1087


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

1086


Why is #define used?

1273


int i=10; printf("%d %d %d", i, i=20, i);

1614


Explain the process of converting a Tree into a Binary Tree.

2660


What is bss in c?

1092


Do string constants represent numerical values?

1387