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 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|ios::in|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.

(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”. 2
Example :
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

(c) Given a binary file APPLY.DAT, containing records of the following class Applicant type 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 below 70.

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