Find the Largest and Smallest and Sort values in array C++
Not what you're looking for?
Write two function in C++ with using arrays to find largest and smallest number.
For example you have 1,43,42,9,8,5. You need arrange them smallest to highest and highest to smallest.
Purchase this Solution
Solution Summary
Two functions: findMin() and findMax() have been coded and tested in main().
Please find the code, Arr1.cpp and executable Arr1.exe attached.
The code is explained with comments. You should be able to use the two functions to achieve what you want including sorting of an array.
For sorting, you need to do a little bit more than just finding minimum and maximum from an array. Simply finding the smallest and/or largest does not automatically lend itself to a sorted array.
Specifically, for an array containing positive integers, you need to repeatedly find the largest number (or smallest number) from the array, print it and replace that largest number with a (say ) negative number, so that it doesn't get picked again in the next iteration. Continue doing this for n elements, where n is the length of the array.
Solution Preview
Two functions: findMin() and findMax() have been coded and tested in main().
Please find the code, Arr1.cpp and executable Arr1.exe attached.
The code is explained with comments. You should be able to use the ...
Purchase this Solution
Free BrainMass Quizzes
C# variables and classes
This quiz contains questions about C# classes and variables.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.