1.

Find the output of the following C++ code considering that the binary file 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();}

Answer»

The output is:

Total Count:500

At Product: 73



Discussion

No Comment Found

Related InterviewSolutions