Page 339 - Computer science 868 Class 12
P. 339

17.  Class indexedarray contains the employee code of 100 employees. Some of the members are given below.
                        Class name                      :    indexedarray
                        Data Members
                        arr[]                           :    int array
                        Member Functions
                        void indexedarray()             :    to initialise the code to 0
                        void fillarray()                :    to input the code in the arr[]
                        void sortarr()                  :    to sort the array variable using the selection sort technique
                        int binarysearch(int[],int)     :   to search and return 1 if an employee code is found in the array object otherwise
                                                            returns 0
                        Specify the class indexedarray giving details of the constructor, void sortarr(), int binarysearch(int[],int). You may assume that
                       other member functions are written for you. You do not need to write the main function.
                    18.  Design a class change to convert a decimal number to its equivalent in base 16 and convert it back to its decimal form.
                        Example:
                        (i)  The decimal number 35 is 23 in base 16.
                       (ii)  The decimal number 107 is 6B in base 16.
                        Some of the members of the class are given below.
                        Class name                      :    change
                        Data Members
                        a[]                             :   integer type array
                        n                               :    integer to be converted to base 16
                        Member Functions
                        change()                        :    constructor to assign 0 to instance variables
                        void input()                    :    accepts integer to be converted to base 16
                        void hexadeci(int)              :    converts decimal integer to hexadecimal form
                        void decidexa()                 :    converts a hexadecimal number back to decimal form
                        Specify the class change giving the details of the constructor and the functions void input(), void hexadeci(int) and void decihexa().
                       The main function need not be written.
                    19.  A class Shift contains a 2D array of order (m*n) where the maximum value for both m and n is 5. Design the class Shift to shuffle
                       the matrix (the first row becomes the last, the second row becomes the first and so on.)
                        Class name                      :   Shift
                        Data Members                    :   mat[][], m,n
                        Member Functions
                        Shift(int mm, int nn)           :    constructor to initialise the data members m=mm, n=nn
                        void input()                    :    enters the elements of the array
                        void cyclic(Shift P)            :      enables the matrix of the object(P) to shift each row upwards in a cyclic manner
                                                            and stores the resultant matrix in the current object
                        void display()                  :    display the matrix elements
                        Define the main() function to create an object and call the other methods accordingly to enable the task of shifting the array elements.
                    20.  Input elements in an array of size 4x3 and print the numbers that are
                        a.  product of all the even numbers in odd positions
                        b.  print all the non-boundary elements
                    21.  Write a program to declare a matrix A [][] of order (M*N) 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.
                        Find the maximum and minimum values in the matrix and display them along with their positions.
                        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


                                                                                                                       337
                                                                                                              Arrays   337
   334   335   336   337   338   339   340   341   342   343   344