COMPUTER SCIENCE DATA FILE HANDLING

OUTSIDE DELHI : 2005

4.a) Observe the program segment given below carefully , and answer the question that follows :

class Member
{ int Member_no ;
char Member_name[20] ;
public :
//function to enter Member details void enterdetails ( ) ;
//function to display Member details void showdetails ( ) ;
//function to return Member_no
int RMember_no( ) {return Member_no ;}
} ;
void Update (Member NEW)
{ fstream File ;
File.open(“MEMBER.DAT” , ios :: binary l ios :: in l ios :: out) ;
Member OM ;
int Recordsread = 0, Found = 0 ;
while (!Found && File.read((char*) & OM, sizeof(OM)))
{ Recordsread++ ;
if (NEW.RMember_no( ) == OM.RMember_no( ))
{ _____________ //Missing Statement File.write((char*) & NEW , sizeof(NEW) ;
Found = 1 ;
}
else
File.write((char*) & OM, sizeof(OM)) ;
}
if (!Found)
cout<<”Record for modification does not exist” ;
File.close( ) ;
}

If the function Update( ) is supposed to modify a record in file MEMBER.DAT with the values of Member NEW passed to its argument, write the appropriate statement for Missing statement using seekp( ) or seekg( ), whichever needed, in the above code that would write the modified record at its proper place.

2.b) Write a function in C++ to count and display the number of lines not starting with alphabet ‘A’ present in a text file“STORY.TXT”.

Examples :

If the file “STORY.TXT” contains the following lines,
The rose is red.
A girl is playing there.
There is a playground.
An aeroplane is in the sky.
Numbers are not allowed in the password.
The function should display the output as 3

4.c) Given a binary file APPLY.DAT, containing records of the following class Applicant type.

3

class Applicant
{ char A_Rno[10] ;
//Roll number of applicant
char A_Name[30] ;
//Name of applicant
int A_Score ;
//Score of applicant public :
void Enrol( )
{ gets(A_Rno) ;
gets(A_Name) ; cin >> A_Score ;
}
void Status( )
{
cout << setw(12) << A_Admno ;
cout << setw(32) << A_Name ;
cout << setw(3) << A_Score << endl ;
}
int ReturnScore( ) {return A_Score ;}
} ;

Write a function in C++, that would read contents of file APPLY.DAT and display the details of those Students whose A_Score is above 70

 

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_filehandling9.php on line 154

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_filehandling9.php on line 154

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

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_filehandling9.php on line 156