Page 250 - C++
P. 250

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

                          The function should calculate the sum and display the following:
                          Sum of Middle Row: 15


                    ​Ans  void ADDMIDROW(int MAT[][10],int R,int C)
                          {
                             int MIDR=0;
                             for (int J=0;J<C;J++)
                                MIDR+=MAT[R/2][J];
                             cout<<”Sum of Middle Row:”<<MIDR<<endl;
                          }
                           OR
                           Any other correct alternative code in C++

                           (½  Mark for correctly writing the loop)
                           (1 Mark for adding middle row elements)
                           (½ Mark for displaying the sum of middle row elements)

                   (c)    T[25][30] is a two dimensional array, which is stored in the memory along the row                                         3
                          with each of its element occupying 2 bytes, find the address of the element
                          T[10][15], if the element T[5][10] is stored at the memory location 25000.

                   Ans  LOC(T[I][J])  = Base(T)+W*(NC*I+J)
                          LOC(T[5][10]) = Base(T)+2*(30*5+10)
                          25000         = Base(T)+2*(30*5+10)
                          Base(T)       = 25000 - 2*(160)
                          Base(T)       = 25000 - 320
                          Base(T)       = 24680

                          LOC(T[10][15])= 24680 + 2*(30*10+15)
                                        = 24680 + 2*(315)
                                        = 24680 + 630
                                        = 25310
                          OR
                           LOC(T[10][15]) = LOC(T[5][10]) + 2(30*(10-5) + (15-10))
                                          = 25000 + 2(150 + 5)
                                          = 25000 + 2(155)
                                          = 25000 + 310
                                          = 25310

                           (1 Mark for writing correct formula (for Row major) OR substituting
                           formula with correct values)
                           (1Mark for correct calculation)
                           (1 Mark for final correct address)


                   (d)    Write the definition of a member function ADDMEM() for a class QUEUE in                                   4
                          C++, to add a MEMBER in a dynamically allocated Queue of Members
                          considering the following code is already written as a part of the program.


                          struct Member
                          {
                            int MNO;
                            char MNAME[20];
                            Member *Next;

                                                     Page #9 of 28
   245   246   247   248   249   250   251   252   253   254   255