Page 200 - C++
P. 200

Price, TotalPrice, Discount, Netprice  float
               Member Functions: Public members:
                •  A constructer to assign initial values of Customer_no as 111, Customer_name as
                    “N.A.”, Quantity as 0 and Price, TotalPrice, Discount and Netprice as 0.
                •  Input( ) – to read data members(Customer_no, Customer_name, Quantity and Price)
                    and invoke Caldiscount().
                •  Caldiscount ( ) – To calculate TotalPrice, Discount and NetPrice
                    Where : TotalPrice = Price*Qty
                                        TotalPrice >=50000 : Discount 25% of TotalPrice
                                        TotalPrice >=25000 and  <50000 : Discount 15% of TotalPrice
                                        TotalPrice <250000 : Discount 10% of TotalPrice
                                        Netprice= TotalPrice-Discount
                •  Show( ) – to display Customer details.

           d.  Give the following class definition answer the question that is follow:                       4

               class University                class College :                class Department :
               {                               private University             protected College
               char name [20];                 { int regno;                   char name[20];
               protected :                     protected:                     char HOD[20];
               char vc[20];                    char principal[25];            public :
               public :                        public :                       void fetchdata(int);
                void estd();                    long no_of_students;   void displaydata( );
                void inputdata();               void readdata();              };
                void outputdata();              void dispdata ( );
               } ;                             };
                   i.     Name the base class and derived class of college.
                   ii.    What will be the size of an object (in bytes) of class Department? What type of
                          inheritance is depicted in the above class definition?
                   iii.   Name the private data members of class College.
                   iv.    Name the members accessible from objects of class Department.

     3     a.  Write  a  function  int  SUM_ALL  (int  ARR  [  ],  int  size)  that  returns  the  sum  of  all  even   2
               elements of the array that are not between 101 and 200.

           b.  Write a function REV_COL (int A [ ][ ], int r, int c) that accepts a two digit array and      3
               reverses the contents of all columns. For eg:
               Original Array:                               Array after Reversed Columns:
                 64    52    5    81                           74    16    42   14
                 32    18   29    72                           56    34    7    90
                 56    34    7    90                           32    18    29   72
                 74    16   42    14                           64    52    5    81


           c.  Given an array A[10][12] whose base address is 10000. Calculate the memory location           3
               of A[2][5] if each element occupies 4 bytes and array is stored
                         i.     Column wise.
                         ii.    Row wise

           d.   Evaluate the following postfix expression:      (show status of Stack after each operation)                 2
               i)   6, 40, 8,/,20,10,–,+,*
               ii)  True, False, True, NOT, True, OR, AND, AND

           e   Define member function delque( ) to perform delete operation on a linked queue where          2

                                                       Page 3 of 6
   195   196   197   198   199   200   201   202   203   204   205