Guys i have this program i created. I have made a random number generator to the array, and then wanted to use to sorting functions, the functions seem to work properly. However, i wanted to make copies of the original array and work with the copies and functions so that the original doesnt get modified. After that, test the number of swaps each sorting function used. I tried copying the array in a copy variable, but its confusing me. Can anyone help me out. Here are the codes, im new to C too by the way.Thank U!

~Love Ava~

Code:`#define SIZE 100`

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

void bubbleSort( int * const array, const int size );

void swap( int *element1Ptr, int *element2Ptr );

void selectionSort( int array[], int length );

/* function prototypes */

int main( void )

{

int array[ SIZE ]; /* declare the array of ints to be sorted (test with bublesort)*/

int copy[SIZE];/*copy of original array to test with selectionsort*/

strcpy(array ,copy );

int i; /* int used in for loop */

srand( time( NULL ) ); /* seed the rand function */

for ( i = 0; i < SIZE; i++ )

array[ i ] = rand() % 90 + 10; /* give each element a value */

printf( "Unsorted array:\n" );

for ( i = 0; i < SIZE; i++ ) /* print the array */

printf( "%d ", array[ i ] );

printf( "\n\n" );

bubbleSort( array, SIZE );

printf( "Sorted array:\n" );

for ( i = 0; i < SIZE; i++ ){ /* print the array */

printf( "%d ", array[ i ] );

}

system ("pause");

return 0;

} /* end function main */

void bubbleSort( int * const array,int size )

{

void swap( int *element1Ptr, int *element2Ptr ); /* prototype */

int pass; /* pass counter */

int j; /* comparison counter */

/* loop to control passes */

for ( pass = 0; pass < size - 1; pass++ ) {

/* loop to control comparisons during each pass */

for ( j = 0; j < size - 1; j++ ) {

/* swap adjacent elements if they are out of order */

if ( array[ j ] > array[ j + 1 ] ) {

swap( &array[ j ], &array[ j + 1 ] );

} /* end if */

} /* end inner for */

} /* end outer for */

} /* end function bubbleSort */

void swap( int *element1Ptr, int *element2Ptr )

{

int hold = *element1Ptr;

*element1Ptr = *element2Ptr;

*element2Ptr = hold;

} /* end function swap */

/* function that selection sorts the array */

void selectionSort( int array[], int length )

{

int smallest; /* index of smallest element */

int i, j; /* ints used in for loops */

/* loop over length - 1 elements */

for ( i = 0; i < length - 1; i++ ) {

smallest = i; /* first index of remaining array */

/* loop to find index of smallest element */

for ( j = i + 1; j < length; j++ )

if ( array[ j ] < array[ smallest ] )

swap( &array[j],&array[smallest] ); /* swap smallest element */

} /* end for */

} /* end function selectionSort */