I still have the same problem of wierd number in my arrays, but this time in a different function:
#include <iostream>
using namespace std;
//First Array
int n[20];
int i, a;
//Second Array
int n2[20];
int i2, a2;
void arraySelection();
void printArrays();
void unionArray();
void intersectionArray();
int main(){ 
    arraySelection();
    printArrays();
    intersectionArray();
    unionArray();
    return 0;
}
void arraySelection(){
    cout << "First array size: ";
    cin >> a;
    cout << "Array elements: " << endl;;
    for (i = 0; i < a; i++){
        cin >> n[i];
    }
    cout << "\nSecond array size: ";
    cin >> a2;
    cout << "Array elements: " << endl;;
    for (i2 = 0; i2 < a2; i2++){
        cin >> n2[i2];
    }
}
void unionArray(){
    const int riemp = 40;       
    int unionNums[riemp];
    int j, x, y, z;
    bool t = false;
    for (j = 0; j <= riemp; j++){
        unionNums[j] = n[j];
        cout << unionNums[j] << " ";
    }
}
Basically I am trying to copy the numbers of my first array n[20] into my unionNums[40] array. It actually does that but it also outputs a series of 0s and other large wierd numbers. 2 Days in the go and still no idea. (PS If i try to gife fixed numbers to the array, so getting rid of the user input, it goes without any problem whatsoever) I also did not bother copyng my intersectionArray and printArray functions since they do things that I don't need anymore at this point
 
    