[Solved] Getting the random values in the new array


May be you want this.

#include<iostream>
using namespace std;
int main() {
    const int m = 8;
    int i, k;
    int A[m] = { 1,2,3,4,5,6,7,8 };
    int B[m];
    k = 0;
    for (i = 0; i < m; i++) {
        if (A[i] % 2 == 0) {
            B[k] = A[i];
            k = k + 1;
        }
    }
    for (i = 0; i < k; i++) {
        cout << B[i];
    }
    cout << endl;
    return 0;
}

3

solved Getting the random values in the new array