Successfully reported this slideshow.

# Write a function imerge that gets pointers to two sorted integer array.docx  ×

# Write a function imerge that gets pointers to two sorted integer array.docx

Write a function imerge that gets pointers to two sorted integer arrays src1[] and src2[] as parameters(the arrays are sorted in ascending order), merges the two arrays in ascending sorted order into a dynamic integer array dst[] and returns to dst[]
The function header is int* imerge (int * src1, int *src2)
Solution
#include <stdio.h>
#include <conio.h>
void main(){
int *arr,src1,src2,tmp,n;
int*imerge(int*src1,intsrc2)
clrscr();
printf(\"Enter how many data you want to sort : \");
scanf(\"%d\",&n);
for(src1=0;src1<nsrc1i++)
scanf(\"%d\",arr+src1);
for(src1=0;src1<n;src1++)
{
for(src2=src1+1;src2<n;src2++){
if( *(arr+src1) > *(arr+src2)){
tmp = *(arr+src1);
*(arr+src1) = *(arr+src2);
*(arr+src2) = tmp;
}
}
}
printf(\"\ \ After Sort\ \");
for(sr1=0;src1<n;src1++)
printf(\"%d\ \",*(arr+src1));
getch();
}
.

Write a function imerge that gets pointers to two sorted integer arrays src1[] and src2[] as parameters(the arrays are sorted in ascending order), merges the two arrays in ascending sorted order into a dynamic integer array dst[] and returns to dst[]
The function header is int* imerge (int * src1, int *src2)
Solution
#include <stdio.h>
#include <conio.h>
void main(){
int *arr,src1,src2,tmp,n;
int*imerge(int*src1,intsrc2)
clrscr();
printf(\"Enter how many data you want to sort : \");
scanf(\"%d\",&n);
for(src1=0;src1<nsrc1i++)
scanf(\"%d\",arr+src1);
for(src1=0;src1<n;src1++)
{
for(src2=src1+1;src2<n;src2++){
if( *(arr+src1) > *(arr+src2)){
tmp = *(arr+src1);
*(arr+src1) = *(arr+src2);
*(arr+src2) = tmp;
}
}
}
printf(\"\ \ After Sort\ \");
for(sr1=0;src1<n;src1++)
printf(\"%d\ \",*(arr+src1));
getch();
}
.