ARRAYS
1. Given a two-dimensional array x of floats, write an expression whose value is twice the
value of the element in the 3rd row and the 2nd column.
2. Write a code that scans two 2x3 (2 rows, 3 columns) arrays of integer, x1 and x2. Write
the code that prints out “TRUE” if and only if every element in x1 is bigger than its
corresponding element in x2 and “FALSE” otherwise
3. Declare an array of integers, that can store the number of vehicles going westbound through
the Holland Tunnel on a particular hour (numbered 0 through 23) on a particular day
(numbered 0 through 6 where 0 denotes Sunday). The innermost dimension should be days.
- Ask the user to fill the array
- Print out the average number of vehicles going westbound per day.
- Print out the busiest traffic hour on Tuesday.
4. SWAPPING
Given an integer N (maximum 25), and N integers followed by 2 integers i k, print the
list after swapping the i-th number with the k-th number
Sample Input:
5
1 4 6 10 7
0 3
Sample Output:
10 4 6 1 7
HOMEWORK
5. Find the value of y in each of the following expressions assume i=3 and X={1,2,3,4,5}:
a. y = X[i] + 1 c. y = X[i+1] e. y = X[i/2]
b. y = X[i]/2 d. y = X[i*2]
6. A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write
an expression whose value is that of the first element in the last row.
7. Write a program that scan a nxm matrix from the user. Your code should print out the
location of all negative number in the array. Moreover it should print “TRUE” if more
integer elements in entire 2-dimensional array are negative than not.
8. Write a program to scan n and m elements into two arrays respectively where the size of
array1 < array2. The program should print “TRUE” if and only if the even-indexed
elements of the first array equal the odd-indexed elements of the second, in sequence.