Question

Consider the following definitions int[ ][ ] numbers = {{1, 2, 3},                                &


Consider the following definitions

int[ ][ ] numbers = {{1, 2, 3},

                                {4, 5, 6} };

The following code below produces

for (int row = numbers.length - 1; row >= 0; row -- )

{

for (int col = 0; col < numbers[0].length; col ++)

{

System.out.print (numbers [row][col]);

}

}

Homework Answers

Answer #1

The code produces the output of 456123

Initially we start row from 1 and col runs from 0 to 2.

which prints numbers[1][0] numbers[1][1] numbers[1][2] which are 456 respectively

then row becomes 0 and col runs from 0 to 2 printing

numbers[0][0] numbers[0][1] numbers[0][2] which are 123 respectively

thus output is 456123

Note no space or new line is added as system.out.print has been used

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following definitions int[ ][ ] numbers = {{1, 2, 3},                                &
Consider the following definitions int[ ][ ] numbers = {{1, 2, 3},                                 {4, 5, 6} }; The following code below produces for (int row = numbers.length - 1; row >= 0; row -- ) { for (int col = 0; col < numbers[0].length; col ++) { System.out.print (numbers [row][col]); } }
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)          ...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)           return true;        else           return false; } public static int Method(int[] numbers, int startIndex) { if(startIndex >= numbers.length)        return 0; if (isTrue(numbers[startIndex]))      return 1 + Method(numbers, startIndex + 1); else      return Method(numbers, startIndex + 1); } What is the final return value of Method() if it is called with the following parameters: numbers = {1, 2, 2, 3, 3,...
public static void main(String[] args) { //Given the following code : int[][] array2D = {{3, 4,...
public static void main(String[] args) { //Given the following code : int[][] array2D = {{3, 4, 5, 1}, {3,6,1,2}, {1,3,6,5}; Answer : 1- All values โ€‹โ€‹of array2D are automatically 0 ? Yes or No 2- What is the value of array2D [3] .length ?________ 3-  The value that array2D.length shows is 12: Yes or No ? 4- Assign the value of 12 to the element in the third row, fourth column : 5- the value obtained when calculating array2D [1] [1]...
[ 1 3 9 -7 0 1 4 -3 2 1 -2 1] find basis for...
[ 1 3 9 -7 0 1 4 -3 2 1 -2 1] find basis for col A. dimension of col A find basis for nul A. dimension of nul A find basis for row A. dimension of row A asap plz, tyouuu
def count_evens(values: List[List[int]]) -> List[int]: """Return a list of counts of even numbers in each of...
def count_evens(values: List[List[int]]) -> List[int]: """Return a list of counts of even numbers in each of the inner lists of values.    >>> count_evens([[10, 20, 30]]) [3] >>> count_evens([[1, 2], [3], [4, 5, 6]]) [1, 0, 2] """   
In Java programming language 11.Create the code for a for loop to print the numbers 1  through...
In Java programming language 11.Create the code for a for loop to print the numbers 1  through 5 inclusive vertically so the output is 1 2 3 4 5 11b What is the output of the following               OUTPUT int i=3; while(int i >0) { System.out.println(i); i--; } 11c What is the output of the following               OUTPUT for(int i=3;i<10;i++) System.out.println(3*i); 11d Create the line of code to print the numbers 10 through 1 decreasing by 1 each time 11e Create the line of code...
2. Consider the following program written in C syntax: void swap(int a, int b) {   ...
2. Consider the following program written in C syntax: void swap(int a, int b) {    int temp;    temp = a;    a = b;    b = temp; } void main() {    int value = 2, list[5] = {1, 3, 5, 7, 9};    swap(value, list[0]);    swap(list[0], list[1]);    swap(value, list[value]); } For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num ==...
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num == 0) return 0; else if (num > 100) return -1; else     return num + tq( num โ€“ 1 ); } Group of answer choices: 0 4 -1 10 Q2: Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)? int mystery(LLNode<Integer> list) {    if (list.getLink() ==...