"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 / sampath

hi friends !
i use java code it simple idea

class Sort
{
public static void main()
{
int A[]={1,18,22,43};
int B[]={3,4,6,20,34,46,55}

int lenA=A.length;
int lenB=B.length;

int n=lenA+lenB; //find the array size


int C[]=new int[n];
int i,j,temp;

for(i=0;i<n;i++) //copy the two array into C array
{
if(i<lenA)
C[i]=A[i];
else
C[i]=B[i-lenA];
}


for(i=0;i<n;i++) //place each element in to correct position
{
for(j=0;j<n;j++)
{
if(c[i]>c[j]) //swapping
{
temp=c[i];
c[i]=c[j];
c[j]=temp;
}
}
}
for(i=0;i<n;i++)// display output
{
System.Out.Print(c[i]+",");
}
}

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of turbo c++?

551


What does obj stand for?

630


How do you print a string on the printer?

578


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

1079


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1862






What is the purpose of templates in c++?

563


Do class declarations end with a semicolon? Do class method definitions?

619


What do you mean by translation unit?

601


What is c++ stringstream?

607


How long will it take to learn programming?

591


Which format specifier is used for printing a pointer value?

577


What do you mean by enumerated data type?

573


What is const in c++?

598


How does c++ structure differ from c++ class?

585


What is vector processing?

670