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

"How will you merge these two arrays? Write the program
Array: A 1 18 22 43
Array: B 3 4 6 20 34 46 55
Output Array: C 1 3 4 6 18 20 22 34 43 46 55"

Answer Posted / foreverkushal

void MergeArray(int *A1, int A1Count, int *A2, int A2Count,
int *A3, int A3Count)
{
int i = 0, j = 0, k = 0;
while(i != A1Count && j != A2Count)
{
if (A1[i] < A2[j]) A3[k++] = A1[i++];
else A3[k++] = A2[j++];
}
if (i != A1Count)
{
while (i < A1Count) A3[k++] = A1[i++];
}
if (j != A2Count)
{
while (i < A2Count) A3[k++] = A2[j++];
}
}

Is This Answer Correct ?    23 Yes 43 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stack? How it can be implemented?

1230


What is static class data?

1113


What is the use of main function in c++?

1020


What is the difference between *p++ and (*p)++ ?

1415


What is null and void pointer?

1111


Is it possible to use a new for the reallocation of pointers ?

1123


what is multi-threading in C++?

1112


Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

4176


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

1238


What is an accessor in c++?

1119


What is the difference between equal to (==) and assignment operator (=)?

1141


What is c++ hiding?

1303


Why is polymorphism useful?

1108


What apps are written in c++?

1142


What is the c++ programming language used for?

1095