void num_exchange(int m, int n){
int temp;
temp = m;
m = n;
n = temp;
}
replicates the supplied numbers and alters them
Use to make your code function
void num_exchange(int& m, int& n){
int temp;
temp = m;
m = n;
n = temp;
}
instead (note the & in the first line).
This is known as passing by reference.
To swap items around, use std::swap.
void arr_exchange(int x[], int){
for (int i = 0; i < 7; i++)
x[i] = 1;
}
works because in C++
void arr_exchange(int x[], int){
is equivalent to
void arr_exchange(int* x, int){
As a result, a pointer is sent here, and the original data is updated.