There are some errors in the below code and I am unable to find them.Kindly resolve the errors and make program error free. #include // including necessary header file #include //header file int merge(int L[],int lsize, int M[],int msize,int res[]); int fill(int[], int*, int[],int,int); // declare a function void print(int[],int,char[]); //define print method int main() //define main method // Declaring two L- and M-array and declaring array size and stored value //{int L[20]={8,9,12,34,56,66,76,89},lsize=8,M[]={2,4,56,66,68,70},msize=6,res[50],rsize=0; printf("Enter size of first array : "); scanf("%d",&lsize); printf("Enter size of second array : "); scanf("%d",&msize); printf("\n\n"); for(int i=0;i
There are some errors in the below code and I am unable to find them.Kindly resolve the errors and make program error free.
#include<stdio.h> // including necessary header file
#include<conio.h> //header file
int merge(int L[],int lsize, int M[],int msize,int res[]);
int fill(int[], int*, int[],int,int); // declare a function
void print(int[],int,char[]); //define print method
int main() //define main method
// Declaring two L- and M-array and declaring array size and stored value
//{int L[20]={8,9,12,34,56,66,76,89},lsize=8,M[]={2,4,56,66,68,70},msize=6,res[50],rsize=0;
//calling a function merge and assigning its value in rsize variable.
rsize=merge(L,lsize,M, msize,res);
print(L,lsize,"Original Array 1"); // Printing the message
print(M,msize,"Original Array 2"); // Print the message
print(res,rsize,"Merged Array"); // Print the message
getch(); //Use to clearscreen
return 0; // Return the value
}
void print( int A[], int len,char mess[]) //defining a function print
{
int i; //declaring i
printf("%s\n",mess);
for(i=0;i<len;i++) // using loop to show iterative statement
printf("%d ",A[i]);
printf("\n\n");
return;
}
int merge(int L[], int lsize,int M[],int msize, int res[]) //defining a function merge
{int lpt=0,mpt=0,rsize=0,dup=0;
while(rsize<(lsize+msize-dup)) //using loop to show iterative statement
{while(L[lpt]==M[mpt])
{lpt++;
dup++;
}
if(L[lpt]<M[mpt]) // Using if condition
{res[rsize++]=L[lpt++];
if(lpt==lsize)
mpt= fill(res,&rsize,M,msize,mpt);
}
else
{res[rsize++]=M[mpt++];
if(mpt==msize) // Using if condition
lpt= fill(res,&rsize,L,lsize,lpt);
}
}
return rsize;
}
int fill( int res[], int *rsize, int A[], int isize,int pt) // Defining a function fill.
{while(pt<isize) // using loop to show iterative statement
{res[*rsize]=A[pt++];
*rsize=*rsize+1;
}
return pt;
}

Step by step
Solved in 3 steps









