Help with Bubble Sort Please!!!

I need to develop an algorithm that performs the bubble sort and need help with it! Here is my code so far, can anyone help me figure out what I am doing wrong?

void BubbleSort(int a[], int arraySize)
{
for( int i = 1; i < arraySize; ++i )
{
for( int a = 0; a < arraySize - 1; a++)
{
if( a[a] > a[a+1])
{
int temp;
temp = a[a];
a[a] = a[a+1];
a[a+1] = temp;
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*C Program To Sort data in ascending order using bubble sort.*/
#include <stdio.h>
int main()
{
    int data[100],i,n,step,temp;
    printf("Enter the number of elements to be sorted: ");
    scanf("%d",&n);
    for(i=0;i<n;++i)
    {
        printf("%d. Enter element: ",i+1);
        scanf("%d",&data[i]);
    }

    for(step=0;step<n-1;++step)
    for(i=0;i<n-step-1;++i)
    {
        if(data[i]>data[i+1])   /* To sort in descending order, change > to < in this line. */
        {
            temp=data[i];
            data[i]=data[i+1];
            data[i+1]=temp;
        }
    }
    printf("In ascending order: ");
    for(i=0;i<n;++i)
         printf("%d  ",data[i]);
    return 0;
}


This one's in google. :)
Topic archived. No new replies allowed.