|
void BubbleSort(int age[]);
|
is a function declaration, it doesn't do anything. I would suggest reading on functions and how to pass arrays into functions.
________________________
There's other problems too. If we change your main function so that it becomes a call to BubbleSort, it has no idea what "age" is. It looks like you're "hardcoding" the values inside the function itself, so you should define the array inside the function.
ex:
1 2 3 4 5
|
void BubbleSort()
{
int age[10] = {22, 23, 65, 76, 54, 25, 85, 48, 52};
//...the rest of your code
}
|
and call it like this
1 2 3 4 5
|
int main()
{
BubbleSort();
return 0;
}
|
again, if you want to pass an already-defined function into your bubble sort, I would read up on how to pass an array into a function.
Another problem:
1 2 3 4
|
for (int i = 0; i < 9; i++)
{
cout << age << "\n";
}
|
You're just printing out the address of age each time. You should print out
age[i]
. You also seem to be confused on whether you're dealing with 10 elements or 9, I would suggest making a more generalized function that can take in any array with a size argument as well.
Also please use code tags, the lack of indentation and spacing makes it harder to read.
If you change your function declaration into a function call, fix the array being passed, and print age[i] instead of age, it should work and the sort logic is correct as well.