CBSE eBooks
CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 1 C++ Revision Tour

1. e. Find the output of the following program: 2
#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
Expected Output (ii) 1 2 3 4 5 6 7 8 9 10 11

Computer Science By Mr. MRK
|