13.6k views
10 votes
6. Write a C++ program to print the largest three elements in an array.


User Goows
by
8.6k points

1 Answer

3 votes

Answer:

if (arr[i] > max) -> max3 = max2, max2 = max , max = arr[i]. else if (arr[i] > max2) -> max3 = max2, max2 = arr[i]. else if (arr[i] > max3) -> max3 = arr[i]. At the end of the loop, we will print all three values.

User Fustigador
by
8.5k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.