1) OPTION C IS CORRECT
2) OPTION B IS CORRECT
3) OPTION C IS CORRECT
4) OPTION D IS CORRECT
5) OPTION C IS CORRECT
whats the answers How many total integers elements are in an array with 4 rows and...
whats the answers For the following code, indicate how many times the loop body will execute for the following input values: 2 1 0? userNum - 3 while (userNum > 0) { // Do something // Get user um from input } 3 Given the following code, how many times will the inner loop body execute? int row: int col; for (row = 0; row < 2; row - row + 1) { for (col = 0; col < 3;...
Consider the following matrix transpose routines: typedef int array[4][4]; void transpose (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[i][j] = src[i][j]; } } } void transpose2 (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[j][i] = src[j][i]; } } } Assume this code runs on...
This is for Java. Create ONE method/function that will return an array containing the row and column of the largest integer i the 2D array. If the largest number is located on row 2, column 1, the method needs to return row 2 and column one. Do not use more than one method. Use the code below as the main. Please comment any changes. in java Given the main, create a method that RETURNS the largest number found in the...
Which of the following can print out all elements in array? int[] [] items = { {0, 1, 3, 4}, {4, 3, 99, 0, 7 }, {3, 2} }; for (int row=0; row < items.length; rowt) O { System.out.println(); for (int col=0; col < items.length; col++) System.out.print( items[row][col] + " "); } for (int row=0; row < items.length; row++) { System.out.println(); for (int col=0; col < items(col).length; col++) System.out.print( items[row][col] + " "); for (int row=0; row < items.length; row++)...
What is wrong with the following code that prints out the elements of a 2x3 array? for (int i 0; i < 3; ++i) { for (int j = 0; j < 2: ++j) { printf("x(%d] [%d] ". %.2f\n", i, j, x[i][j]); O Expression ali]li] is incorrect O There is nothing wrong with the code 0 %2t is invalid O It is printing for a 3x2 array
Consider the following code: *How many elements in the array A are * also in the array B? Assume B is sorted. */ 01: int overlap (int* A, int* B, int N) 02:{ 03: int count = 0; 04: for (int i = 0; i < N; ++i) 05: 06: int x A [i 07: 08 int pos lower_bound (B, B+N, x) - B; if (pos N && B [pos] 09: 10: 11: 12: == x ) { +count; 13:...
7. The code segment given sorts an array. Show how this works on the given array by redrawing the array each time one of the entries changes value. const int Isize·6; // list size int list [lsize]; int j, x; for (int i = !size-1; i > 0; i-) { x = list [i]; ji; for (int k = i-1 ; k >= 0; k-) { if (list [k] > x) f j -k; x = list(k); list [j] list...
Line number 9 contains the code line that declares the result array ( asked in another question of this exam). On Line number 11 where col_ contains the correct statement ( asked in another question of this exam) Question: Write the codeline (single line) to compute the matrix multiplication of "frstMatrix" and "scndMatrix". For this question you will write a code line for line number 17 1 package ok4; 2 //This java program multiplies two matrices 3 //represented with two...
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
14 Points Bonus Question: Consider the following transpose routine: typedef int array (212): void transposel (array dst, array sre) int i, j; for(i=0; i<2; i++) { for (-0; j 2; j++){ dst sre[BG); Assume that this code runs on a machine with the following properties: • sizeof(int) = 4 • The src array starts at address and the dst array starts at address 16 There is a single L1 cache that is direct-mapped, write through, write allocate, with a block...