[Solved] C++ Inputting numbers into array and outputting them [closed]


int num[10];

    for(int i = 0; i < 10; i++){
        i = num[i];
        cout << num[i];
    }

In the above piece of code you haven’t stored anything to the array you declared. So it would print some random values out.

The following would work as you think :

int num[10]={0,1,2,3,4,5,6,7,8,9};

    for(int i = 0; i <= 10; i++){

        cout << num[i];
    }

solved C++ Inputting numbers into array and outputting them [closed]