"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
What is guard code in c++?
What are the advantages of prototyping?
What is the most powerful coding language?
Write my own zero-argument manipulator that should work same as hex?
What parameter does the constructor to an ofstream object take?
What is the arrow operator in c++?
What do c++ programmers do?
What is a responder chain?
Write a Program to find the largest of 4 no using macros.
What is virtual table?
Is java made in c++?
Why do we use vector in c++?
Can we make copy constructor private in c++?
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
Who made c++?