Can't see my error

Most likely its a simple mistake but as a beginner I don't see it. Maybe I did't pay attention in class when this was taught.
Thanks for the feedback.

#include<iostream>
using namespace std;

void sortDescending(int a[], int length);

int main(){
int theArray[5] = { 5, 4, 8, 9, 3 };
cout << sortDescending(theArray, 5) << endl;
return 0;
}

void sortDescending(int a[], int length){
int smaller;
for (int x = 0; x<length - 1; x++){
for (int i = 0; i<length - 1; i++){
if (a[i]<a[i + 1]){
smaller = a[i];
a[i] = a[i + 1];
a[i + 1];
}
}
}
}
Please put [code][/code] tags around your code.

What is the problem? How do you know there is an error? Is the compiler giving you one? If so, what is it?
cout << sortDescending(theArray, 5) << endl;

This line doesn't make sense. Your function is a void function yet you are trying to get it to output "something" to the screen.

If you want to print your array contents out you could write a function for that after you've sorted it.
Topic archived. No new replies allowed.