Page 340 - Computer science 868 Class 12
P. 340

OUTPUT:
                     Original matrix:
                     8 7 9 3
                     -2 0 4 5
                     1 3 6 -4
                     Largest Number: 9 Row: 0 Column: 2
                     Smallest Number: -4 Row: 2 Column: 3
                 22.  Write a program to declare a matrix A [][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the number of columns such
                    that both M and N must be greater than 2 and less than 20. Allow the user to input integers into this matrix. Perform the following
                    tasks on the matrix:
                     Display the input matrix
                     Sort the elements of the matrix in ascending order using any standard sorting technique and rearrange them in the matrix.
                     Output the rearranged matrix.
                     Test your program with the given sample data and some random data.
                     INPUT:
                     M=3
                     N=4
                     Entered values: 8,7,9,3,-2,0,4,5,1,3,6,-4
                     OUTPUT:
                     Original matrix:
                     8 7 9 3
                     -2 0 4 5
                     1 3 6 -4
                     Rearranged matrix:
                     -4 -2 0 1
                     3 3 4 5
                     6 7 8 9
                 23.  Given two sorted arrays A and B of size p and q. Write a Java program to merge elements of A with B by maintaining the sorted
                    order, i.e., fill A with the first p smallest elements and fill B with the remaining elements.
                     Example:
                     Input:
                     int[] A = { 1, 5, 6, 7, 8, 10 }
                     int[] B = { 2, 4, 9 }
                     Output:
                     Sorted Arrays:
                     A: [1, 2, 4, 5, 6, 7]
                     B: [8, 9, 10]
                 24.  Write a Java program that returns the missing letter from an array of increasing letters (upper or lower). Assume there will always
                    be one letter missing in the array.
                     Example:
                     Original array of elements:
                     [p, r, s, t]
                     Missing letter in the array: q
              D.  Assertion and Reasoning Based Question.
                 Assertion: Java ‘while’ loop executes a set of statements repeatedly for a certain number of time depending on the given condition.
                 Reason: As soon as the control statement match the condition, the ‘while’ loop terminates.
                 (a)  Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
                 (b)  Both Assertion and Reason are true, but Reason is not the correct explanation for Assertion.
                 (c)  Assertion is true and Reason is false.
                 (d)  Assertion is false and Reason is true.

                                         Previous Years' Questions


                  1. A matrix M[–6...10m 4...15] is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1025,
                    find the address of M[4][8] when the matrix is stored in Column Major Wise.                [ISC 2023]



                338338  Touchpad Computer Science-XII
   335   336   337   338   339   340   341   342   343   344   345