Question: Write a function to find the largest number and the second largest number from an array. Since a function cannot return multiple values, we need
Write a function to find the largest number and the second largest number from an array. Since a
function cannot return multiple values, we need to use pointers to implement the function as follows:
void findtwolargestint a int n int largest int secondlargest;
When passed an array a of length n the function will search a for its largest and secondlargest
elements, storing them in the variables pointed to by largest and secondlargest respectively.
In addition to findtwolargest function, you are expected to implement main function. main function
will ask for user inputs; call findtwolargest; print the result as the example output below.
The input is the array size followed by the elements in the array. Please name the program as
findLargests.c
Example input:
Example output:
Largest number:
Second largest number:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
