the program is supposed to get numbers from the user into a dynamically allocated array, next it is support to use 2 other functions to sort and average said array, when input certain values into the array (1-8 for example) the array will display unsorted twice as opposed to once and then again but sorted. When i give the array different values it may only display the array once with or without the average displayed afterwards.
I tried running the code and the sort() function is an infinite loop. When sorting the array the variable swap might be set to true and then never changed(thus, the while(swap) is always true). I found this algorithm for sorting arrays: http://www.programmingsimplified.com/c/source-code/c-program-bubble-sort
Here's the solution(only the sort function, the rest works just fine):