#include <iostream>
usingnamespace std;
int main(){
int board[3][3];
int i,j;
for(j=0;j<3;j++){
cout << "\n";//i needed this to put in line breaks
for(i=0;i<3;i++){
board[j][i] =0;
cout << board[j][i];
if(i!=3){cout << " ";}
}
}
return 0;
}
sorry
it should have been this:
if(i==2){cout << "\n";}
element 3 does not exist it's [0][0], [0][1], [0][2]. \n [1][0], [1][1], [1][2]. \n [2][0], [2][1], [2][2].
Do you see what you did wrong though?
the first time you were not comparing your were assigning, the second it was comparing element 3, which didn't exist so the use of if(i==2){cout << "\n";} should work exactly as you wanted, however you found a way around that by putting the newline in the outer loop.