Question: Computer Lab #2 Revision of the C Programming Language Task 1. Look through the given source code and analyze the quicksort program that uses a

 Computer Lab #2 Revision of the C Programming Language Task 1.
Look through the given source code and analyze the quicksort program that

Computer Lab #2 Revision of the C Programming Language Task 1. Look through the given source code and analyze the quicksort program that uses a simple static array to store user data. #include #include #define ARRAY_MAX 5 // The compare function compares two values received as parameters. 1/ We have to specify this function with general parameter types. Since // being passed to the sort, such approach insures the type safety. // In other words, sort does not care about types of clements being sorted int compare(const void>, const void *) { // Returning value: e, if ab. double da-(double*), *-(double); If("dac db) return-1; else if (*da=="db) returne; else return 1; > int main() double dARRAY_MAX); int i; for(i=;I CARRAY_MAX: 1.) printf("Enter a number:"); scanf("%f", Bd[1]); ) qsort(d, ARRAY_MAX. Sizeof(double), compare); for(1=8; CARRAY_MAX;1.-) printf("%1% *[1]); ) return; ) Put a breakpoint inside the compare function, and check the values of pointer variables "da and *db. Is this code correct? Why do we use a function pointer? How can a function pointer be passed as a parameter? Why do the parameters of compare function have void" types? Please recall from C. why the last parameter of scanf should be a pointer. Task 2. Modify the given program so that the array size is not fixed anymore. Ask a user for the actual array size before reading the array elements. Consider dynamic memory management (recall it from C). Task 3. Having the examples above, define the most important usage areas of pointers. Task 4. Develop and implement a function that receives some string value as a parameter and reverses it. In the implementation you cannot use any special functions from external string libraries

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!