Write a function, sort, that accepts an array of integers, and the number of elements in the array and sorts the array in ascending order (basic sort)

1
Write a function, sort, that accepts an array of integers, and the number of elements in the array and sorts the array in ascending order (basic sort)

LANGUAGE: C++

CHALLENGE:

Write a function, sort, that accepts an array of integers, and the number of elements in the array and sorts the array in ascending order (basic sort)

SOLUTION:



void sort(int array[],int size){
   int hold;
   int i;
   for ( int pass = 0; (pass< size-1) ; pass++)
   for ( i = 0; i<size-1; i++)
   if (array[i] > array[i+1]){
      hold = array[i];
                array[i] = array[i+1];
                array[i+1] = hold;
   }
}"

One comment

Add comment