Share
Explore BrainMass

C/C++ Console Program that Uses Arrays

Create a program in which a user is asked for how many values (s)he wants to enter (maximum 50), then:
Asks for the values and stores them into an array of double.
Sorts the values in ascending order according to the following algorithm, where size is the number of doubles to be sorted:
for i=0..size-2
check all the values between position i and size-1 to find the smallest one
swap the smallest value and the one in position i
Prints the sorted array to the console.

Solution Preview

I have attached the C++ source code and also the executable. The source code is well-commented and should provide enough explanation. In case it proves insufficient, though, I have explained the code below.

I assume that you are reasonably familiar with basic input and output, so I will not explain those parts. If you find any difficulty, however, I will definitely add more explanation, so please let me know.

The array is stored in the array variable <I>arr</I> and the size of this array is stored in the variable <I>n</I>. After reading ...

Solution Summary

The solution provides a C/C++ Program that uses arrays.

$2.19