Need some help with arrays
I am trying to get my program to return the smallest number and then output my list in reverse order. My largest function works but I can't figure out how to do the smallest or the reverse order.
Please help :confused: :D
Code:
int main()
{
printArray (listA, arraySize);
cout << endl << endl;
cout << "Largest Number: "
<< listA [indexLargestElement(listA, arraySize)]
<< endl << endl;
cout << "Smallest Number: "
???????
//output the reverse order
printArrayReverse (listA, 0, 5);
cout << endl << endl;
return 0;
}
{
void printArray (const int list[], int listSize)
{
int index;
for (index = 0; index < listSize; index++)
cout << list[index] << " ";
}
int indexLargestElement (const int list[], int listSize)
{
int index;
int maxIndex = 0;
for (index = 1; index < listSize; index++)
if (list[maxIndex] < list[index])
maxIndex = index;
return maxIndex;
}
int indexSmallestElement (const int list[], int listSize)
{
?????????????????????????
}
//function print the elements of an int array in reverse
void printArrayReverse (const int list[], int listSize)
{
????????????????????
}