WIX1002 Fundamentals of Programming Tutorial 5 Arrays
WIX1002 Fundamentals of Programming Tutorial 5 Arrays
Tutorial 5 Arrays
f. After initialize the array, modify the value of the above array to
b.
int[] num = new num[10];
for(int k=0; k<=num.length(); k++)
sum+=num;
c.
int [][]t = new int[3][];
t[1][2] = 5;
d.
int i=4;
int []score = new int[5];
score [1] = 78;
score[++i] = 100;
3. Determine the values of each element of array marks. Assume the array was declared
as:
int[] marks = new int[5];
int i = 0, j = 1;
marks[i] = 12;
marks[j] = marks[i] + 19;
marks[j-1] = marks[j] * marks [j];
marks[j*3] = marks[i+1];
marks[++j] = marks[i]%5;
marks[2*j] = marks[j-1];
4. Write the statements that display the number of occurrence of the word "the" (case
sensitive) in a string array name sentence.
5. Write the statements that display the string array name sentence in reverse order.
Each string element must be displayed in reverse order as well.
6. Write the statements that generate 1 random integer within 0 – 255. Convert the
number to binary and store the bit into an 8 bit array. Then, display the binary
number.