1. ## Bubble sort, Help!!!!

Hi

I have been stuck trying to work this but something is wrong.

If any one can give me a hand i'd really appreciate it.

2. ## Salem...

>for (i = 0, sorted = 1; i < n-1 ; i++)

This can be write like this too, no?
for (i=0, sorted=1; i < n ; ++i );

3. ## ...

hmmm
Code:
```#include <stdio.h>

#define MAX 10 //array max size

int main(void)
{
int nArray[MAX] = {1,2,3,4,5,6,7,8,9,10};
int nI;

for(nI = 0; nI < MAX; ++nI)
printf("%d\n",nArray[nI]);

getchar(); //wait for the user to press a char
return 0;
}```
This works fine.. he prints well all the elements of the array,
same with nI++.

4. ## I still cant get it salem..

for (i = 0, sorted = 1; i < n-1 ; i++)
I dont think that is needed here n-1, using the < operator (not the <=) this will alone go until n-1, I tried looping an array of 10 elements with your code, and he counted until 8 (0 - 8). but he should go until 9 (0-9) so I did change the n-1 to i<n and this works fine..

5. I think what is needed is too write a correct bubblesort. Bubblesort is a nested loop. You are counting form size of array down, and then swapping from 0 to the count. It is not a for in a while but a for in a for.

6. ## Ohh, now I get it Salem.

Now you explained why, thanks.
Because, in my book they don't write it like that

7. I think you got this part of the code fixed but when getting input from the user that will go into an array, you do not use the address of operator (&). Since an array is a form of a pointer it is not needed.