1. ## bubling code question

Hello guys I m new in c me just started 1 week ago found a bubling sort code on google but there is some stuff inside that i dont understand
Code:
```
/* bubble.c by detour@metalshell.com
*
* Use the very simple and slow bubble sort method to
* sort an array of integers.
*
* http://www.metalshell.com/
*
*/

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define ARRAY_SIZE 20

void print_array(int *array) {
int x;
for(x = 0; x < ARRAY_SIZE; x++) {
if(x != ARRAY_SIZE-1)
fprintf(stdout, "%d, ", array[x]);
else
fprintf(stdout, "%d\n", array[x]);
}
}

int main() {
int iarray[ARRAY_SIZE];
int x, y, holder;

// Seed rand()
srand((unsigned int)time(NULL));

for(x = 0; x < ARRAY_SIZE; x++)
iarray[x] = (int)(rand() % 100);

fprintf(stdout, "Before Sort\n---------------\n");
print_array(iarray);

// Bubble sort method.
for(x = 0; x < ARRAY_SIZE; x++)
for(y = 0; y < ARRAY_SIZE-1; y++)
if(iarray[y] > iarray[y+1]) {
holder = iarray[y+1];
iarray[y+1] = iarray[y];
iarray[y] = holder;
}

fprintf(stdout, "\nAfter Sort\n---------------\n");
print_array(iarray);

}```
in the buble sort that if statement I totally don't get it help me please to understand it more thanks...

2. It's set up for an ascending sort, so greater values found lower in the array, need to be swapped with lower values, found higher in the array.

The normal is to print the array from low array subscripts (0,1,2 etc.) to the high subscripts.

Inside the if statement, is the swap mechanism. Array[i] must put it's higher value into a temporary holder, then it can be assigned the value of the lower Array[i+1], then the Array[i + 1] is ready to receive the temporarily stored value, itself, completing the swap.