Computer Science, asked by aditriagarwal1, 8 months ago

WAP TO STORE 10 NUMBERS IN A ARRAY A[] ABD 5 NUMBERS IN A ARRAY B[] AND THEN MERGE INTO ARRAY C []

Answers

Answered by Soñador
2

Answer:

#include<iostream.h>

#include<conio.h>

void input1(int a[],int n)

{

cout<<"\nEnter elements of first array ";

for(int i=0;i<n;i++)

{

cin>>a[i];

}

}

void input2(int b[i],int m)

{

cout<<"\nEnter elements of second array ";

for(int i=0;i<m;i++)

{

cin>>a[i];

}

}

void merge(int a[],int b[],int c[],int m, int n)

{

for(int i=0;i<n+m;i++)

{

if(i<n)

{

c[i]=a[i];

}

else

{

c[i]=b[i];

}

}

}

void show(int c[],int m, int n)

{

for(int i=0;i<n+m;i++)

cout<<c[i]<<endl;

}

void main()

{

clrscr();

int a[100],b[100],n,m,c[100];

cout<<"\n Enter size of array 1";

cin>>n;

cout<<"\N Enter size of array 2";

cin>>m;

input1(a,n);

input2(b,m);

merge(a,bc,m,n);

show(c,m,n);

getch();

}

The value of m and n in above program are:

n=10

m=5

(as given in the question)

Similar questions