I'm really struggling to comprehend nested for loops and so have done as followed:
int arr[][] = new int[10][3];
int i, j;
arr[0][0]=21;
arr[1][0]=41;
arr[2][0]=61;
arr[3][0]=81;
etc.
... to get the following output:
21 21 21
41 41 41
61 61 61
81 81 81
etc.
I understand this is highly inefficient, so have attempted to construct a nested for loop which clearly doesn't work:
for(i=21;i<81;i+=20)
{
for(j=0;j<arr[i].length;j++)
{
arr[i][j] = i+j;
}
}
A guide in the right direction is greatly appreciated. Thanks.
forloops to me. What exactly is your problem?