Important Questions

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

CBSE CLASS XII

Ans:

#include<iostream.h>
const int dividor= 5;
{
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;
}

Q.1.e. Find the output of the following program
#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

Q.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.
//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. Ravi Kiran
Email Id : [email protected]