Hi guys....
It has been a long time since i left this forum..
Now i'm actually back studying c++ and here is the little problems that i got with the 2D
array question.
I need to create this pattern using the 2D array:
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
and this is one that i've tried by my own:
#include <iostream>
using namespace std;
int main(){
const int COLUMNS=5;
int number[5][COLUMNS];
for(int i=0; i<5; i++)
{
for(int j=0; j<COLUMNS; j++)
{
if((number[i][j])%2==0){
cout<<"1";
}else cout<<"0";
}
cout<<endl;
}
}
but it appears that my code is not right by displaying this kind of output
11111
11111
11111
11111
11110
i'm not sure whats wrong and yet, i still not familiar with 2d arrays..So i hope someone could help me out here by telling me what should i do for the codes that i've written.
Thank You :)