I am in sort section of pset3. I am implementing a bubble sort algorithm, but it seems that, although values[] is being sorted, elements are being moved one position forward in memory. For example:
For the command ./generate 5 2
- The values given are:

the array of values
But when sorted the array looks like this (I am using printf just to see how the array is looking, which and where are the values):

I WONDER WHAT IS THE ISSUE HERE AND ANY CLUE TO SOLVE IT.
The code for void sort(int values[], int n) is this:
void sort(int values[], int n) { // TODO: implement an O(n^2) sorting algorithm for(int h = 0; h < n ; h++) { for( int i = 0; i < n; i++) { if (values[i+1] < values[i]) { int temp = values[i]; values[i] = values[i +1]; values[i+1] = temp; printf("cycle = %i\n", i); printf(" values[i] --> %i\n", values[i]); printf(" values[i+1] --> %i\n", values[i+1]); printf(" values[i+2] --> %i\n", values[i+2]); printf(" values[i+3] --> %i\n", values[i+3]); printf(" values[i+4] --> %i\n", values[i+4]); printf(" values[i+5] --> %i\n\n", values[i+5]); } else { } } } }