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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;

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<lsize;i++){
printf("Enter value %d of first array : ",i);
scanf("%d",&L[i]);
}

printf("\n\n");

for(int i=0;i<msize;i++){
printf("Enter value %d of second array : ",i);
scanf("%d",&M[i]);
}

//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;

}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education