Page 299 - C++
P. 299

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

                          Any other correct C++ code for the required function definition.

                           (1 Mark for correctly writing the loop)
                           (1 Mark for correctly checking condition for even/odd locations)
                           (½ Mark for adding the element in the next position to the even
                           positioned elements)
                           (½ Mark for incrementing the element by 10 for odd positioned
                           elements)

                   (b)    Write a definition for a function SUMMIDCOL(int MATRIX[][10],int N,int M) in C++,                                 2
                          which finds the sum of the middle column’s elements of the MATRIX (Assuming N
                          represents number of rows and M represents number of columns, which is an odd
                          integer).
                          Example: if the content of array MATRIX having N as 5 and M as 3 is as follows:
                              1       2        1
                              2       1        4
                              3       4        5
                              4       5        3

                              5       3        2

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

                    ​Ans   void SUMMIDCOL(int MATRIX[][10],int N,int M)
                           {
                             int mid=M/2;
                             int sum=0;
                             for(int i=0; i<N; i++)
                             {
                                 sum=sum+MATRIX[i][mid];
                             }
                             cout<<” Sum of Middle Column”<<sum;
                           }

                           OR
                           Any other correct C++ code for the required function definition

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

                   (c)    ARR[15][20] is a two-dimensional array, which is stored in the memory along the                                   3
                          row with each of its elements occupying 4 bytes. Find the address of the element
                          ARR[5][15], if the element ARR[10][5] is stored at the memory location 35000.

                   Ans     ROW MAJOR:
                           Loc(ARR[I][J]) =BaseAddress + W [( I – LBR)*C + (J – LBC)]

                           (where   W=size of each element = 4 bytes,  R=Number of
                           Rows=15, C=Number of Columns=20 )

                           Assuming LBR = LBC = 0


                                                     Page #9 of 28
   294   295   296   297   298   299   300   301   302   303   304