Page 28 - C++
P. 28

Ans       (i)    class City
                                (1 mark for correct answer)

                         (ii)   None
                                (1 mark for correct answer)

                         (iii)   Data   members:    Country_Id,    Country_Name[25],      State_Population,

                                City_Population
                                Member  functions:    Display_Country(),    New_State(),  Print_State(),

                                Get_Population(), New_City(), Show_City()
                                (1 mark for correct answer)

                         (iv)   90 bytes for object of class Country & 63 bytes for object of class State
                                (1/2 mark for each correct answer)

        Q3     (a)   Write the definition of function named Array_Swap() that will accept an integer array &        3

                     its size as arguments and the function will interchange/swap elements in such a way that
                     the first element is swapped with the last element, second element is swapped with the

                     second last element and so on, only if anyone or both the elements are odd.

                            E.g. if initially array of seven elements is:
                                           5, 16, 4, 7, 19, 8, 2

                            After execution of the above function, the contents of the array will be:
                                           2,16, 19, 7, 4, 8, 5

               Ans




















                     (½ Mark for correct function header)

                     (½ Mark for correct loop)
                     (1  Mark for correct checking of odd elements in each pair)

                     (1 Mark for swapping the elements)

               (b)   An array A[50][30] is stored along the row in the memory with each element requiring 4         3
                     bytes  of  storage.  If  the  element  A[10][15]  is  stored  at  21500,  then  find  out  the  base

                                                        Page No. 11
   23   24   25   26   27   28   29   30   31   32   33