Important Questions

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

CBSE CLASS XII

2005 Outside Delhi :

1.b Name the header files to which the following belong:
(i) puts( ) (ii)isalnum( )

Ans. (i) puts( ) - stdio.h
(isalnum( ) - ctype.h

1.c. Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.2
#include<iostream.h>
const int dividor 5;
void main( )
{ Number = 15;
for(int Count=1;Count=<5;Count++,Number -= 3)
if(Number % dividor = = 0)
cout<<Number / Dividor;
cout<<endl;
else
cout<<Number + Dividor <<endl;

Ans.
#include<iostream.h>
const int dividor= 5;
void main( )
{ int Number = 15;
for(int Count=1;Count<=5;Count++,Number -= 3)
if(Number % dividor = = 0)
{ cout<<Number / Dividor;
cout<<endl;
}
else
cout<<Number + Dividor <<endl;
}

1.e. Find the output of the following program2
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Change(char Msg[],int Len)
{ for(int Count=0;Count<Len;Count++)
{ if(islower(Msg[Count]))
Msg[Count] = toupper(Msg[Count]);
else if(isupper(Msg[Count]))
Msg[Count] = tolower(Msg[Count]);
else if (isdigit(Msg[Count]))
Msg[Count]=Msg[Count]+1;
else Msg[Count] = ‘*’;
}
}
void main( )
{ char Message[ ]=”2005 Tests ahead”;
int Size=strlen(Message);
Change(Message,Size);
cout<<Message<<endl;
for(int C=0,R=Size – 1; C<=Size/2;C++,R--)
{ char Temp=Message[C];
Message[C]=Message[R];
Message[R]=Temp;
}
cout<<Message<<endl;
}

Ans. Output:
3116*tESTS*AHEAD
DAEHA*SSTEt*6113

1.f Observe the following program GAME.CPP carefully, if the value of Num entered by the user is 14, choose the correct possible output(s) from the options from (i) to (iv), and justify your option. 2
//Program:GAME.CPP
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
int Num,Rndnum;
cin>>Num;
Rndnum=random(Num)+7;
for(int N=1;N<=Rndnum;N++)
cout<<N<<” “;
}

Output
Options:

(i) 1 2 3 (ii) 1 2 3 4 5 6 7 8 9 10 11
(iii) 1 2 3 4 5 (iv) 1 2 3 4

Ans. Expected Output
(ii) 1 2 3 4 5 6 7 8 9 10 11

Paper By Mr. MRK
Email Id : [email protected]@yahoo.com