COMPUTER SCIENCE DATA FILE HANDLING

4.b) Consider the class declaration.

class FLIGHT
{ protected:
int flight_no;
char destination[20];
float distance;
public:
void INPUT( );
//To read an object from the keyboard
void write_file(int);
//To write N objects into the file,
//Where N is passed as argument.
void OUTPUT( ); //To display the file contents on the monitor.
};

Complete the member functions definitions.

2000:

Q 4 (a) Name two member functions of ofstream class.

Q 4 (b) Assuming the class DRINKS defined below, write functions in C++ to perform the following:

(i) Write the objects of DRINKS to a binary file.
(ii) Read the objects of DRINKS from binary file and display them on screen when DNAME has value "INDY COLA".

class DRINKS
{ int DCODE;
char DNAME[13]; //Name of the drink
int DSIZE; //Size in liters float
DPRICE;public:
void getdrinks( )
{cin>>DCODE>>DNAME>>DSIZE>>DPRICE;}
void showdrinks( )
{cout<<DCODE<<DNAME<<DSIZE<<DPRICE< <endl;}
char *getname( ){return DNAME;}
};

1999:

Q 4 (a) Differentiate between functions read() and write().

Q 4 (b) Assuming the class FLOPPYBOX, write a function in C++ to perform following:

(i) Write the objects of FLOPPYBOX to a binary file.
(ii) Reads the objects of FLOPPYBOX from binary file and display them on screen.

class FLOPPYBOX
{ int size;
char name[10];
public:
void getdata(){cin>>size;gets(name);}
void showdata(){cout<<size<<" <<name<<endl;}
};

1998:

Q 4(a) Write name of two member functions belonging to fstream class.

Q 4(b) Assuming the class EMPLOYEE given below, write functions in C++ to perform the following:

(i) Write the objects of EMPLOYEE to a binary file.
(ii) Read the objects of EMPLOYEE from binary file and display them on the screen.

class EMPLOYEE
{ int ENO;
char ENAME[10];
public:
void GETIT( )
{ cin>>ENO;
gets(ENAME);
}
void SHOWIT( )
{ cout< < ENO<<ENAME<<endl;
}
};


 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/data_filehandling11.php on line 159

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/data_filehandling11.php on line 159

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/data_filehandling11.php on line 161

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/data_filehandling11.php on line 161