Question: Finding 2 largest numbers in a list TwoLargest should be written as a function that is called in main. The user should be able to

Finding 2 largest numbers in a list

TwoLargest should be written as a function that is called in main. The user should be able to enter any list

of numbers that they wish.

Hint: You can use parts of the code from the bubblesort example such as

vector_get() to create the list of numbers. Additionally, length(A) = n can also be found with A.size() in

C++ so TwoLargest can be written with only one argument.

proceedure TwoLarges

t(A = [a1...an], length(A) = n)

large_1 = 0

large_2 = 0

for i = 1 to n

if A[i] > large_1

large_2 = large+1

large_1 = A[i]

else if large_2 < A[i]

large2 = A[i]

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!