Page 294 - C++
P. 294

CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
                                      (Sub Code: 083 Paper Code 91 Outside Delhi)


                           ●    ​Assume all the required header files are already being included in
                               the code.
                           ●​     ​The function random(n) generates an integer between 0 and n-1

                           void main()
                           {
                             randomize();
                             int N=random(3),M=random(4);
                             int DOCK[3][3] = {{1,2,3},{2,3,4},{3,4,5}};
                             for(int R=0; R<N; R++)
                             {
                                  for(int C=0; C<M; C++)
                                     cout<<DOCK[R][C]<<"  ";
                                  cout<<endl;
                             }
                           }
                           (i)                     (ii)
                           1 2 3                   1 2 3
                           2 3 4                   2 3 4
                           3 4 5

                           (iii)                   (iv)
                           1 2                     1 2
                           2 3                     2 3
                                                   3 4

                   Ans     Correct Options :  (ii) and (iii)

                           Maximum value of N = 2
                           Maximum value M  = 3

                           (1 Mark for writing the correct options)
                           NOTE: No marks to be awarded for writing any other option or any other
                           combination

                           (½ Mark for writing correct Maximum value of N)
                           (½ Mark for writing correct Maximum value of M)


              2.   (a)     Differentiate between protected and private members of a class in context of                                 2
                           Object Oriented Programming. Also give a suitable example illustrating
                           accessibility/non-accessibility of each using a class and an object in C++.

                   Ans
                           private                                  protected
                           Implicit Visibility Mode                 Explicit Visibility Mode

                           Not accessible to member functions of  Accessible to member functions of
                           derived class                            derived class
                           Example:
                           class A
                           {
                                 int X;


                                                     Page #4 of 28
   289   290   291   292   293   294   295   296   297   298   299