Declare a two dimensional array with 10 rows and 10 columns and initialise:
a) All the elements of its third row to 10
b) All the elements of its 6th column to 20
c) And all the other elements to 5
in that order.
I have the following piece of code that is pretty much the core of the program:
Expand|Select|Wrap|Line Numbers
- import uwejava.*;
- import glos.*;
- public class exc4
- {
- public int nums;
- for(int y = 0; y < nums.length; ++y)
- for(int x = 0; x < nums[i].length; ++x)
- if(y == 2)
- nums[y][x] = 10;
- else if(x == 19)
- nums[y][x] = 20;
- else
- nums[y][x] = 5;
- }