Page 254 - C++
P. 254

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

                             while(F.read((char*)&obj,
                                             sizeof(obj)))
                             {
                                if(strcmp(obj.RDEPT(),“MATHS”)==0)
                                   count++;
                             }
                             cout<<”Number of MATHS teachers :”<<count<<endl;
                             F.close();  ​//IGNORE
                          }
                          OR
                          Any other correct function definition

                          (½ Mark for opening TEACHERS.DAT correctly)
                          (½  Mark for reading records from TEACHERS.DAT)
                          (½ Mark for comparing  DEPT of type MATHS(ignore case sensitive checking)
                          with strcmp or strcmpi)
                          (½ Mark for displaying the incremented count for matching records)

                   (c)    Find the output of the following C++ code considering that the binary file                                      1
                          BOOK.DAT exists on the hard disk with a data of 200 books.

                          class BOOK
                          {
                            int BID;char BName[20];
                          public:
                            void Enter();void Display();
                          };
                          void main()
                          {
                            fstream InFile;
                            InFile.open("BOOK.DAT",ios::binary|ios::in);
                            BOOK B;
                            InFile.seekg(5*sizeof(B));
                            InFile.read((char*)&B, sizeof(B));
                            cout<<"Book Number:"<<InFile.tellg()/sizeof(B) + 1;
                            InFile.seekg(0,ios::end);
                            cout<<" of "<<InFile.tellg()/sizeof(B)<<endl;
                            InFile.close();
                          }

                   Ans   ​Book Number: 7 of 200

                           (½ Mark for displaying correct value of InFile.tellg()/sizeof(B) + 1)
                           (½ Mark for displaying correct value of InFile.tellg()/sizeof(B))


             SECTION B - (Only for candidates, who opted for Python)
             1     (a)    Which of the following can be used as valid variable identifier(s) in Python         2
                          (i)​  ​total
                          (ii)​  ​7Salute
                          (iii)​  ​Que$tion
                          (iv)​  ​global
                   Ans    (i)​ total


                                                     Page #13 of 28
   249   250   251   252   253   254   255   256   257   258   259