Sorting an Array
Posted on 2006-11-28
Hello, I am currently playing around in Dev C++ and would like to know how to I would like to create a function that is called from my main function that allows the user to enter 5 integers. Once the integers are entered it should print the array out to the console.
After printing the array in the order the integers were entered I should call a function to sort the array and then for a second time print the array, which now should display the integers in ascending sorted order.
I want to use this to sort my array if possible:
void selection_sort(int a, int length)
for (int count = 0 ; count < length - 1 ; count++)
int minimum_from(int a, int position, int length)
int min_index = position;
for (int count = position + 1 ; count < length ; count
if (a[count] < a[min_index])
min_index = count;
void swap(int& first, int& second)
int temp = first;
first = second;
second = temp;