Page 346 - C++
P. 346

CBSE AISSCE 2017-2018 Marking Scheme for Computer Science
                                       (2018-2019 Sub Code: 083       Paper Code: 91)

                     (f)   Look at the following C++ code and find the possible output(s) from the options                                          2
                           (i) to (iv) following it. Also, write the highest and lowest values that can be
                           assigned in the array A.
                           Note​:
                           ●   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 A[4], C;
                             for(C=0; C<4; C++)
                               A[C]=random(C+1)+10;
                             for(C=3; C>=0; C--)
                               cout<<A[C]<<"@";
                           }
                           (i)                                     (ii)
                           13@10@11@10@                            15$14$12$10$

                           (iii)                                   (iv)
                           12@11@13@10@                            12@11@10@10@


                    Ans    (i) and (iv)
                           A​  = 10      A​   = 13
                            Min​         Max​
                           (1 Mark for writing the correct options)
                           OR
                           (½ Mark for writing only option (i) OR only option (iv))
                           NOTE: No marks to be awarded for writing any other option or any other
                           combination

                           (½ Mark for writing each correct Maximum and Maximum value in array A)

              2.    (a)    Which function(s) out of the following can be considered as overloaded                                 2
                           function(s) in the same program? Also, write the reason for not considering the
                           other(s) as overloaded function(s).
                           void Execute(char A,int B);  //Function 1
                           void Execute(int A,char B);  //Function 2
                           void Execute(int P=10);      //Function 3
                           void Execute();              //Function 4
                           int  Execute(int A);         //Function 5
                           void Execute(int &K);        //Function 6

                    Ans    Option [i]
                           Functions 1,2,3 are overloaded

                           Reason: Function 4,5,6 would give ambiguity for Function 3
                                        OR Any equivalent valid reason
                           OR



                                                        Page #4/35
   341   342   343   344   345   346   347   348   349   350   351