"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 are exceptions c++?
Who made c++?
What is the difference between containment and delegation?
What is functions syntax in c++?
what is the use of void main() in C++ language?
What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard
Which is the best c++ software?
What do you mean by persistent and non persistent objects?
What is the function to call to turn an ascii string into a long?
Is c++ platform dependent?
What does override mean in c++?
How do I use arrays in c++?
What is encapsulation in c++ with example?
What is istream c++?
What are the benefits of oop in c++?