Page 98 - C++
P. 98

void PRODUCT :: ModifyQty ( )

        {

        fstream Fil;

        Fil.open (“PRODUCT.DAT” , ios : : binary | ios : : in | ios : : out);

        int MPno;

        cout<<“Product No to modify quantity :”; cin>>MPno;

        while( Fil.read ((char*) this, sizeof (PRODUCT)))

        {

        if (MPno ==Pno)

        {

        cout<<“present quantity:” <<Qty<<endl;

        cout<<“changed quantity:”; cin>>Qty;
        int position = ________; //Statement 1


        ___________________; //Statement 2
        Fil.write ((char*) this, sizeof (PRODUCT)); // Re-writing the Record


        }
        }

        Fil.close( );

        }

        (b) Write a function in C++ to count the no. of “Me” or “My” words present in a text file “DIARY.TXT”.   [2]

        If the file “DIARY.TXT” content is as follows :

        My first book was Me and My

        family. It gave me chance to be known to the world.

        The output of the function should be

        Count of Me/ My in file : 4

        (c) Write a function in C++ to search for a laptop from a binary file “LAPTOP.DAT” containing the objects of
        class LAPTOP (as defined below).                                                                     [3]

        The user should enter the Model No and the function should search and display the details of the laptop.
        class LAPTOP

        {

        long ModelNo;

        float RAM, HDD;

        char Details[120];
   93   94   95   96   97   98   99   100   101   102   103