Important Questions

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

CBSE CLASS XII

(d) //Function definition
void Display(int A[][100],int N)
{
cout<<”Middle Row:”<<endl;
for(int i=0;i<N;i=i+1)
cout<<A[N/2][i]<<” “;
cout<<endl;
cout<<”Middle Column:”<<endl;
for(i=0;i<N;i=i+1)
for(int i=0;i<N;i=i+1) – For Borland C++
cout<<A[i][N/2]<<” “;
}

OR

Any other correct equivalent function definition

(e) Evaluation of the given postfix expression is explained below Operator Scanned Stack Content
15 15
3 15, 3
2 15, 3, 2
+ 15, 5
/ 3
7 3, 7
+ 10
2 10, 2
* 20

OR

Any other method of evaluating the postfix expression is shown.

4. (a) Statement 1: File.seekg(-1*sizeof(L),ios::cur);

OR

File.seekg(Rec*sizeof(L));

OR

File.seekp(-1*sizeof(L),ios::cur);

OR

File.seekp(Rec*sizeof(L));

OR

Any equivalent correct method of calculating size of the record in place of sizeof operator.
File.write((char *) &L,sizeof(L));

OR

Any equivalent correct method of calculating size of the record in place of sizeof operator.

(b) //Function to count the word in STORY.TXT file
void thewordCount()
{
ifstream Fil(“STORY.TXT”);
char String[20];
int C=0;
while(!Fil.eof())
{
Fil>>String;
if(strcmpi(String,”the”)==0)
C=C+1;
}
cout<<C<<endl;
Fil.close();
}
OR
void thewordCount()
{
ifstream Fil(“STORY.TXT”);
char String[20];
int C=0;
while(!Fil.eof())
{
Fil>>String;
if(strcmp(String,”the”)==0 || strcmp(String,”The”)==0)
C=C+1;
}
cout<<C<<endl;
Fil.close();
}

OR

void thewordCount()
{
ifstream F(“STORY.TXT”);
char Str[4];
int C=0;
while(F.getline(Str,4,’ ‘))
{
if(strcmp(Str,”the”)==0 || strcmp(Str,”The”)==0)
C=C+1;
}
cout<<C<<endl;
F.close();
}

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