Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

4. (a) Observe the program segment given below carefully, and answer the question
that follows : 1
class Labrecord
{
int Expno;
char Experiment[20];
char Checked;
int Marks;
public :
//function to enter Experiment details
void EnterExp( );
//function to display Experiment details
void ShowExp ( ) ;
//function to return Expno
char RChecked ( ) {return Checked;}
//function to assign Marks
void Assignmarks(int M)
{ Marks = M;}
};
void MpdifyMarks()
{ fstream File;
File.open(“Marks.Dat”,ios::binary|ios::in|ios::out);
Labrecord L;
int Rec = 0;
while (File.read((char*)&L, sizeof(L)))
{
if(L.RChecked( )== ‘ N ‘ )
L.Assignmarks(0)
else
L.Assignmarks(10)
//statement 1
//statement 2
Rec ++ ;
}
File.close ();
}
If the funption ModifyMarks() is supposed to modify Marks for the records in the file MARKS.DAT based on their status of the member Checked (containing value either V or ‘N’). Write C++ statements for the statement 1 and statement 2, where, statement 1 is required to position the file write pointer to an appropriate place in the file and statement 2 is to perform the write operation with the modified record.

(b) Write a function in C++ to print the count of the word the as an independent word natextfileSTORY.TXT. 2
For example, if the content of the file STORY.TXT is There was a monkey in the zoo. The monkey was very naughty. Then the output of the program should be

(c) Given a binary file SPORTS.DAT, containing records of the following
structure type :
struct Sports
{
char Event[20];
char Participant[10][30];
};
Write a function in C++ that would read contents from the file SPORTS.DAT and creates a file named ATHLETIC.DAT copying only those records from SPORTS.DAT where the event name is “Athletics”.

Paper By Mr. Ravi Kiran
Email Id : [email protected]