This is an exercise for my class, and I'm not sure how to go about the function that needs to be made to reverse order.
#include <iostream>
#include <iomanip>
void reverseorder(int[], int);
void printout(int[], int);
const int SIZE = 10;
int main()
{
int number[SIZE] = {10, 15, 20, 25, 30, 35, 40, 45, 50, 55};
reverseorder(number, SIZE);
printout(number, SIZE);
}
void reverseorder(int number[], int SIZE)
{
for (int i = 0; i < SIZE; i++)
{
number[i] = number[SIZE - i];
return;
}
}
void printout(int number[], int SIZE)
{
for (int i = 0; i < SIZE; i++)
{
std::cout << number[i] << std::setw(5);
}
std::cout << std::endl;
}
I know for a fact that fnc void reverseorder(int number[], int SIZE) is not correct, because that's the only thing left that needs to be done. If you know the answer but don't want to give it to me straight up then any hints would be very much appreciated too! Thanks guys
EDIT: Currently the output is: SalvGis-MBP:c++ programming$ ./a.out 503709838 15 20 25 30 35 40 45 50 55
But I want it to be 55 50 45 40 35 30 25 20 15 10
Not sure why the 503709838 is being produced. Somebody mentioned the first iteration being broken, that probably explains it.