Page 29 - C++
P. 29

address of the array and the memory address of element stored at location A[30][25]?
               Ans  Row-major Formula:-                  A[I][J]= B+ W*((I-L r)*N c + (J-L c))

                     Nr=50, Nc=30, B=?, W=4, Lr=0, Lc=0, A(10,15)=21500
                     A[10][15]= B + 4*((10-0)*30 + (15-0))

                     21500= B + 4*(300+15)

                     21500=B + 4*315
                     B=21500 – 1260

                     B=20240


                     A[30][25] = 20240 + 4*((30-0)*30 + (25-0))
                     A[30][25] = 20240 + 4*(900+25)

                     A[30][25] = 20240 + 4*925

                     A[30][25] = 23940


                     (1 Mark for using correct formula for row major)

                     (1/2 Mark each for substituting formula with correct values for calculation of Base
                     address & address of A[30][25] element)

                     (1/2 Mark for each correct final answer of Base address & address of A[30][25])
               (c)   Write the definition of a member function Q_Insert() for a class Exam_Queue in C++             4

                     to insert a new Application information in a dynamically allocated queue whose code is
                     already  given  below  as  a  part  of  the  program(assume  all  necessary  header  files  are

                     included in program):































                                                        Page No. 12
   24   25   26   27   28   29   30   31   32   33   34