Page 214 - C++
P. 214
(c) Write a function in C++ to perform insert operation in a Circular Queue containing Player’s information (represented
with the help of an array of structure PLAYER) .
struct PLAYER
{ long PID ; //Player ID
Char Pname[20] ; //Player Name } ; [4]
(d) Write a function TRANSFORM(int A[4][3]) in C++ to swap the elements of the first column with the corresponding
elements of last column of array A. [2]
(e) Convert the expression (A – 5) * 6 + (10 / B) / 2 to corresponding postfix expression . Also show the status of operator
stack after each step. [2]
Q.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 :
void enterdetails( ); //function to enter Member details
void showdetails( ); // function to display Member details
int RMember_no( ); //function to return Member_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( ))
{
……………………… // statement 1
………………………. // statement 2
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 the file MEMBER.DAT with the values of Member NEW
passed to its argument, write the appropriate statements for the Statement 1 using seekp( ) or seekg( ) whichever
needed, Statement 2 using read( ) or write( ) method, whichever needed in the above code that would write the
modified record at its proper place. [1]
(b) Assume a text file “coordinate.txt” is already created. Using the file create a C++ function to count the number of
words having first character capital. Example :
Do Less Thinking and pay more attention to your heart. Do Less Acquiring and pay more Attention
to what you already have. Do Less Complaining and pay more Attention to giving.
Output will be : Total words are 11. [2]
4