Multi Arrays

Hi guys, im trying to print out my array. Im not sure why i get crazy numbers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main()
{
    int rashad[3][5]=
    {
        {1, 2, 3, 4, 5},
        {2, 3, 4, 5, 6},
        {3, 4, 5, 6, 7}
    };
    
    for(int i=0; i<3; i++)
    {
        cout << rashad[i] << endl;
    }
    for(int j=0; j < 5; j++)
    {
        cout << rashad[j] << endl;
    }
    
    return 0;
}
closed account (48T7M4Gy)
Your array elements are rashad[i][j] not rashad[i] or rashad[j].
So you need to nest the loops.
Topic archived. No new replies allowed.