void find_two_largest(int a[], int n, int *largest, int *second_largest);
* When passed an array a of length n, the function will search a for its largest and second-largest elements, storing them in the variables pointed to by largest and second_largest respectively.
Finish the code below to match the input and output. Pointer are required.
#include <stdio.h>
void find_two_largest(int a[], int n, int *largest, int *second_largest);
int main(void)
{
int n, largest, second_largest;
scanf("%d", &n); //Numbers will be entered
int a[n];
//Enter n integers separated by spaces
for (int i = 0; i < n; i++)
scanf(" %d", &a[i]);
find_two_largest(a, n, &largest, &second_largest);
if (n == 0)
//No numbers were entered.
else if (n == 1)
//Only one number was entered. Largest:
else
//Largest: , Second Largest:
return 0;
}
void find_two_largest(int a[], int n, int *largest, int *second_largest)
{
// Your code here (Using pointer to finish)
}
Example input:
0
Example output:
No numbers were entered.
Example input:
1
67
Example output:
Only one number was entered. Largest: 67
Example input:
5
5 6 7 8 9
Example output:
Largest: 9, Second Largest: 8