New to C++, so I apologize in advance for my ineptitude.
I need to write a function outside of function Main that checks the elements of an array (that were entered by the user) to see if they are over 10. If they are, I need to print that number of elements as well as a list of the elements themselves. If they aren't, I need to display a message that says there aren't any.
I've tried various things, but this is the one that I keep coming back to. Can you help out?
void print_over_ten(const int list[], int length)
//list[] contains user entered elements
//length contains the length of the array, list[]
{
int index=0; //counter
int amount; //number of elements over 10
int number_over_ten; //variable for numbers over ten
cout << "\nThese numbers are over ten: ";
if (index > 10 && index <= length)
{
number_over_ten = index-1;
cout << number_over_ten << " ";
index++;
}
else
cout << "\nThere are no numbers over 10.\n";
amount = index;
cout << "There are " << amount << " numbers over 10.\n";
}
I think most of that is probably wrong, so feel free to trash that.
Any help is greatly appreciated. Thanks!