Page 82 - C++
P. 82

S.Enter();
                             ofile.write (Char*) & S, sizeof(s));
                             cout << "more (Y/N)";
                             cin>>ch;
                             }
                             ofile.close();
                             }

                             (½ Mark for opening Bus.Dat correctly)
                             (1 Mark for reading each record from Bus.Dat)
                             (1 Mark for comparing value returned by EndTo( ) with “Cochin”)
                             (½ Mark for displaying the matching record)

                                                                OR

                             (1 Mark for opening STUDENT.Dat correctly)
                             (1 Mark for S.Enter())
                             (1 Mark for writing each record into the file)

                      (c)    Find the output of the following C++ code considering that the binary file    (1)
                             PRODUCT.DAT exists on the hard disk with a list of data of 500 products.
                             class PRODUCT
                             {
                                           int PCode;char PName[20];
                                    public:
                                           void Entry();void Disp();
                             };
                             void main()
                             {
                                         fstream In;
                                    In.open("PRODUCT.DAT",ios::binary|ios::in);
                                    PRODUCT P;
                                    In.seekg(0,ios::end);
                                    cout<<"Total Count: "<<In.tellg()/sizeof(P)<<endl;
                                    In.seekg(70*sizeof(P));
                                    In.read((char*)&P, sizeof(P));
                                    In.read((char*)&P, sizeof(P));
                                    cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
                                    In.close();
                             }
                                                                OR

                             Which file stream is required for seekg() ?

                      Ans.  Total Count:500
                             At Product: 73

                                                                OR


                                                             18
   77   78   79   80   81   82   83   84   85   86   87