"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 guard code in c++?

644


What are the advantages of prototyping?

567


What is the most powerful coding language?

618


Write my own zero-argument manipulator that should work same as hex?

588


What parameter does the constructor to an ofstream object take?

613






What is the arrow operator in c++?

561


What do c++ programmers do?

557


What is a responder chain?

575


Write a Program to find the largest of 4 no using macros.

584


What is virtual table?

624


Is java made in c++?

583


Why do we use vector in c++?

602


Can we make copy constructor private in c++?

595


A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

3243


Who made c++?

613