"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 / manish podiyal

#include<iostream.h>
class array
{
int a[15],b[15],c[15];
public:
void setdata()
{
a[10]={1,18,22,43,NULL};
b[10]={3,4,6,20,34,46,55,NULL};
}
void output()
{
while(a[i]!=NULL)
{
for(i=0;i<15;i++)
{
if(a[i]< b[i])
{
c[i]=a[i];
i++;
}
else if(a[i] > b[i])
{
c[i]=b[i];
i++;
}
}
}
if(a[i]==NULL)
{
c[i]=b[i];
i++;
}
}
};
void main()
{
array o;
o.setdata();
o.output();
}

Is This Answer Correct ?    28 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an adaptor class or wrapper class in c++?

605


Can we sort map in c++?

592


How should a contructor handle a failure?

688


What is bubble sort c++?

572


Write about the access privileges in c++ and also mention about its default access level?

615






What is guard code in c++?

640


Should the member functions which are made public in the base class be hidden?

558


What is the default access level?

621


What is the array and initializing arrays in c++?

506


Explain differences between new() and delete()?

616


Write about the local class and mention its use?

607


Do the names of parameters have to agree in the prototype, definition, and call to the function?

599


What is difference between array and vector in c++?

557


Is java easier than c++?

588


How should runtime errors be handled in c++?

609