"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 do nonglobal variables default to a) auto b) register c) static
What is a linked list in c++?
Which programming language is best?
Write a recursive program to calculate factorial in c++.
What is the use of class in c++?
What is a tuple c++?
what is the difference between linear list linked representaion and linked representation? what is the purpose of representing the linear list in linked represention ? is it not avoiding rules of linear represention?
How do you clear a map in c++?
What is the benefit of learning c++?
Do you know about C++ 11 standard?
How would you implement a substr() function that extracts a sub string from a given string?
What are the two shift operators and what are their functions?
Is c++ built on c?
What is the difference between a pointer and a link in c ++?
What are punctuators in c++?