First of all what value do you have in this pice of code? int temp;
? You can't tell because in every single compilation it will have different value - you should initialize your value to not have trash value from memory. Next question is: why you assign this temp value to your array?
If you want to stick with your solution I would change reverse function like this:
void reverse(int arr[], int count)
{
int temp = 0;
for (int i = 0; i < count/2; ++i)
{
temp = arr[count - i - 1];
arr[count - i - 1] = arr[i];
arr[i] = temp;
}
for (int i = 0; i < count; ++i)
{
std::cout << arr[i] << " ";
}
}
Now it will works but you have other options to handle this problem.
Solution using pointers:
void reverse(int arr[], int count)
{
int* head = arr;
int* tail = arr + count - 1;
for (int i = 0; i < count/2; ++i)
{
if (head < tail)
{
int tmp = *tail;
*tail = *head;
*head = tmp;
head++; tail--;
}
}
for (int i = 0; i < count; ++i)
{
std::cout << arr[i] << " ";
}
}
And ofc like Carlos Abraham says use build in function in algorithm
library