Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

=+ a. a family deciding whether to buy a new car

Answered: 1 week ago

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago