I think he is need of pattern code i.e using only two for loops and which is the better approach.
Understand the pattern as a i*jmatrix such that
when i = even print the even j values as '1' and
when j = odd print the odd j values as '1'
else where print '0'.
Comment