"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
Explain the purpose of the keyword volatile.
What is guard code in c++?
How do you find out if a linked-list has an end?
What is abstraction with real time example?
What is the difference between object-oriented programming and procedural programming?
Which bit wise operator is suitable for putting on a particular bit in a number?
How would you differentiate between a pre and post increment operators while overloading?
When is the destructor called?
If I is an integer variable, which is faster ++i or i++?
Which function should be used to free the memory allocated by calloc()?
Difference between class and structure.
Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
What does #define mean in c++?
Explain the benefits of proper inheritance.