Question: C Programming d) Complete the following function: void find_smallest(int arr[], int n, int *small, int *second_small); When passed an array arr of length n, this

C Programming

C Programming d) Complete the following function: void find_smallest(int arr[], int n,

d) Complete the following function: void find_smallest(int arr[], int n, int *small, int *second_small); When passed an array arr of length n, this function will search for its smallest and second smallest elements and store them in the variables pointed to by smallest and second_smallest, respectively. To receive full marks, you are required to use a pointer to access array elements. Up to four marks will be deducted if you use array subscripting in your function body To simplify your solution, you can assume that the elements of the array arr are distinct and it has at least with two elements. No error handling is required. [8 points] #include void find_smallest (int arr[], int n, int *small, int *second_small); int main() { int all = {9, 8, 5, 2, 3, 7); int smallest, second_smallest; find_smallest(a, 6, &smallest, &second_smallest); printf("smallest is $d, second smallest is $a", smallest, second_smallest); return 0; } Sample output: smallest is 2, second smallest is 3

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!