40195: Given an array a, write an expression that refers to the first element of the array.
a(0)
40196: Given an array a, declared to contain 34 elements, write an expression that refers to the last element of the array.
a(33)
40197: Assume that the array arr has been declared. Write a statement that assigns the next to last element of the array to the variable x, which has already been declared.
x = arr(arr.length - 2)
40198: Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the year in order (i.e., January, February, etc.), write a statement that writes to standard output the element corresponding to October. Do not write anything else out to standard output.
Console.Write(monthSales(9))
40211: We informally define the term corresponding element as follows: The first element in an array and the last element of the array are corresponding elements. Similarly, the second element and the element just before the last element are corresponding elements. The third element and the element just before the element just before the last element are corresponding elements -- and so on. Given an array a, write an expression for the corresponding element of a(i).
a(a.length - 1 - i)
40199: Given that an array named a with elements of type Integer has been declared, assign 3 to its first element.
a(0) = 3
40200: Assume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declared. Write a single statement to assign the value 30000 to the first element of this array.
salarySteps(0) = 30000
40500: Given that an array named a has been declared, assign -1 to the last element in a.
a(a.length - 1) = -1
40201: Assume that an array of integers named salarySteps that contains exactly five elements has been declared. Write a statement that assigns the value 160000 to the last element of the array salarySteps.
salarySteps(salarySteps.length - 1) = 160000
40202: Assume that an array named a containing exactly 5 integers has been declared and initialized. Write a single statement that adds 10 to the value stored in the first element of the array.
a(0) += 10
40203: Given that an array of Integers named a with 30 elements has been declared, assign 5 to its last element.
a(29) = 5
40204: Assume that an array of Integers named a has been declared with 12 elements. The integer variable k holds a value between 0 and 6. Assign 15 to the array element whose index is k.
a(k) = 15
40205: Given that an array named a whose elements are of type Integer has been declared, assign the value -1 to the last element in a.
a(a.length - 1) = -1
40206: An array of Integers named a has been delcared with 12 elements. The integer variable k holds a value between 0 and 6. Assign 9 to the element just after a[k].
a(k+1) = 9
40207: An array of Integers named a has been declared with 12 elements. The integer variable k holds a value between 2 and 8. Assign 22 to the element just before a[k].
a(k-1) = 22
40208: Assume that an array of Integers named a that contains exactly five elements has been declared and initialized. In addition, an Integer variable j has also been declared and initialized to a value somewhere between 0 and 3. Write a single statement that assigns a new value to the element of the array indexed by j. This new value should be equal to twice the value stored in the next element of the array (i.e. the element after the element indexed by j).
a(j) = a(j+1) * 2
40209: Assume that an array of integers named a has been declared and initialized. Write a single statement that assigns a new value to the first element of the array. The new value should be equal to twice the value stored in the last element of the array.
a(0) = a(a.length - 1) * 2
No comments:
Post a Comment