When using
Code:
MAX= sizeof(array) / sizeof(array[0]);
MAX is assigned a value of 1. This is because sizeof(array) returns the size of the pointer to the array (4 bytes) and sizeof(array[0]) returns the size of an integer (4 bytes). You should pass the number of elements as an extra parameter to the SetArray and SortArray functions.
When outputting, you output all 20 elements of the array, but only the first one was initialized for the reason mentioned above.
For your sorting you should use
Code:
for(int i=0; i<MAX-1; i++)
{
for(int j=i + 1; j<MAX; j++)
and not
Code:
for(int i=0; i<=MAX; i++)
{
for(int j=i + 1; j<=MAX; j++)
In main() you should also reset i to 0 before displaying the sorted array.