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,...
3. What will be the value of w after the following section of code executes: int...
3. What will be the value of w after the following section of code executes: int w = 4, q = 3; if (q > 5)       if (w == 7)           w == 3;       else            if (w > 3)               w = 1;            else               w = 0; A.0            B.1              C.2          D.3 4. What will be the value of b after the following section of code executes: int a = 4, b = 0; if (a...
C ++ program that will read in prices and store them into a two-dimensional array //...
C ++ program that will read in prices and store them into a two-dimensional array // It will print those prices in a table form and the lowest price. // EXAMPLE // Input: // Please input the number of rows from 1 to 10 // 2 // Please input the number of columns from 1 to 10 // 3 // // Input price of item (0,0): 2 // Input price of item (0,1): 4 // Input price of item (0,2):...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in airplane const int COLS = 4; void menu(); //displays options void displaySeats(char[][COLS]); void reserveSeat(char [ROWS][COLS]); int main() { int number=0; //holder variable char seatChar[ROWS][COLS]; for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { seatChar[i][j] = '-'; } } int choice; //input from menu bool repeat = true; //needed for switch loop while (repeat...
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]...
I NEED THIS ANSWER FOR MY DATA STRUTURE CLASS: Consider the following two methods: public static...
I NEED THIS ANSWER FOR MY DATA STRUTURE CLASS: 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...
class Ex1{ 2. public static void main(String args[]){ 3. int x = 10; 4. int y...
class Ex1{ 2. public static void main(String args[]){ 3. int x = 10; 4. int y = new Ex1().change(x); 5. System.out.print(x+y); 6. } 7. int change(int x){ 8. x=12; 9. return x; 10. } 11. } Can you please explain this entire code and what is happening?
Java question Consider the following: 1 class SnoopDogg { 2 int count; 3 } 4 class...
Java question Consider the following: 1 class SnoopDogg { 2 int count; 3 } 4 class Test { 5 public static void main ( String [] args ) { 6 SnoopDogg myCount = new SnoopDogg (); 7 myCount.count = 0; 8 int times = 0; 9 increment( myCount, times ); 10 System.out.println( myCount.count ); 11 System.out.println( times ); 12 } 13 public static void increment (SnoopDogg sd, int times ) { 14 sd.count = sd.count + 1; 15 times =...
exampleInput.txt 1 2 3 0 2 3 4 0 1 3 5 0 1 2 6...
exampleInput.txt 1 2 3 0 2 3 4 0 1 3 5 0 1 2 6 1 5 6 8 2 4 6 7 3 4 5 9 10 5 8 9 4 7 9 6 7 8 6 How can I detect when 'cin' starts reading from a new line. The amount of numbers in each row is unknown. I need them in type 'int' to use the data. Also, it will be executed like so, "./a.out < sampleInput.txt".
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT