I am trying to write a program to sort an array of 10 numerical values from smallest to largest
I'm lost at the swapping part. How do I write that part so I am able to swap the values so they are listed from smallest to largest?
The lines 8-10 have quite descriptive instructions, but lets look at two details first:
1. What does happen on line 32?
2. What does happen on line 39?
What you are trying to implement is a bubble sort algorithm.
Swaping values, the easy way is to use a third temporay variable like so:
int temp = i;
i = j;
j = temp;
With this 3 lines the values ov i and j are swaped.
Also you could read about bubblesort and make the algorithm a little bit better only using 1 function for the sorting.