Code in C:
Write the three sorting functions and the three comparison functions necessary to perform the following actions. No need to write the algorithm for this problem.
Sort an array of integers in ascending order.
Sort an array of doubles in descending order.
Sort an array of characters in ascending order.
In the main program, call your functions to sort the three arrays already declared and initialized.
Note: You must use the qsort function as presented in the slides. You cannot use any other method to sort the arrays.
```c
#include <stdio.h>
#include <stdlib.h>
int compare_int_asc(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
}
int compare_double_desc(const void *a, const void *b) {
return (*(double*)b - *(double*)a);
}
int compare_char_asc(const void *a, const void *b) {
return (*(char*)a - *(char*)b);
}
int main(void) {
int array1[8] = {67, 98, 23, 11, 47, 13, 94, 58};
double array2[8] = {-6.4, 2.65, 32.745, -3.9, 2.2, 11.742, -23.523, 0.0};
char array3[8] = {'a', 'G', '?', 'm', '#', 'B', 'n', '%'};
qsort(array1, 8, sizeof(int), compare_int_asc);
qsort(array2, 8, sizeof(double), compare_double_desc);
qsort(array3, 8, sizeof(char), compare_char_asc);
printf("Sorted array1 (ascending): ");
for (int i = 0; i < 8; i++) {
printf("%d ", array1[i]);
}
printf("
");
printf("Sorted array2 (descending): ");
for (int i = 0; i < 8; i++) {
printf("%.3lf ", array2[i]);
}
printf("
");
printf("Sorted array3 (ascending): ");
for (int i = 0; i < 8; i++) {
printf("%c ", array3[i]);
}
printf("
");
return 0;
}
```