Page 189 - C++
P. 189

(c) Find the output of the following C++ code considering that the binary file CLIENT.DAT exists on the hard
        disk with a data of 1000 clients:                                                                    (1)

        class CLIENT

        {

               int Ccode; char CName[20];

        public:

               void Register(); void Display():

        };

        void main()

        {

        fstream CFile;
        CFile.open("CLIENT.DAT",ios::binary|ios::in);


        CLIENT C;
        CFile.read((char*)&C, sizeof(C));


        cout<<"Rec: "<<CFile.tellg()/sizeof (C)<<endl;
        CFile.read((char*)&C, sizeof(C));

        CFile.read((char*)&C, sizeof(C)):

        cout<<"Rec:"<<CFile.tellg()/sizeof(C)<<endl;

        CFile.close():

        }

        Ans.

        Output

        Rec: 1
        Rec: 3
                                                             OR

        (c) Which file stream is required for tellg() function ?                                             (1)

        Ans. fstream.h  or ifstream.h

        Q5 (a) What do you understand by Primary Key & Candidate Keys?                                       (2)

        Ans. An attribute or set attributes which are used to identify a tuple uniquely is known as Primary Key. If a
        table has more than one such attributes which identify a tuple uniquely than all such attributes are known as
        Candidate Keys.
   184   185   186   187   188   189   190   191   192   193   194