Page 440 - Computer science 868 Class 12
P. 440

int value, int size, int upper, int lower)   :   store the value in the given row position and column position of the matrix in
                                                         clockwise fashion to generate a spiral matrix as shown above
                     void display()                   :  calls generate (int, int, int, int, int, int) and generates spiral matrix
                     Define class Spiral giving details of the methods mentioned above. Also write main() method to create object and call other
                    methods accordingly to enable the task.
                 24.  Design a class Change to perform string related operations. The details of the class are given below:   [ISC 2010]
                     Class name                       :  Change
                     Data Members
                     str                              :  stores the word
                     newstr                           :  stores the changed word
                     len                              :  stores the length of the word
                     Member Functions
                     Change()                         :  default constructor
                     void inputword()                 :  to accept a word
                     char caseconvert(char ch)        :  converts the case of the character and returns it
                     void recchange(int)              :  extracts characters using  recursive technique  and  changes its  case using
                                                         caseconvert() and forms a new word
                     void display()                   :  displays both the words
                     Define class Change giving details of the methods mentioned above. Also write main() method to create object and call other
                    methods accordingly to enable the task.
                 25.  A class called BinAdd is defined to perform addition of two binary numbers stored as string. The details of the class is given below.
                     Class name                       :  BinaAdd
                     Data Members
                     String num1, num2                :  to store the two binary numbers
                     String res                       :  to store the result of binary addition
                     Member Methods are BinAdd()      :  constructor to initialise data members to null
                     void addzero()                   :   to add leading zero’s to the smaller number to make length of both numbers
                                                         equal if required
                     void addnum(int p)               :   to add the two binary numbers according to the rules of binary addition using
                                                         recursive technique and store the result in res
                     void display()                   :  to display the numbers and their sum
                     Define class BinAdd giving details of the methods mentioned above. Also write main() method to create object and call other
                    methods accordingly to enable the task.

                                          Previous Years' Questions


                  1. The following function task() is a part of some class. Assume ‘m’ and ‘n’ are positive integers, greater than 0. Answer the
                    questions given below along with dry run/working.                                          [ISC 2023]
                    int task(int m, int n)
                    {
                    if(m==n)
                    return m;
                    else if(m>n)
                    return task(m–n,n);
                    else
                    return task(m,n–m);
                    }



                438438  Touchpad Computer Science-XII
   435   436   437   438   439   440   441   442   443   444   445