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
1.f) Observe the following program GAME.CPP carefully, if the value of Num 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
2
Ans: Expected Output
(ii) 1 2 3 4 5 6 7 8 9 10 11
2004 Annual Paper:
1.b) Write the names of the header files to which the following belong:(i) gets( ) (ii) strcmp( ) (iii)abs( ) (iv)isalnum( ).
2
Ans:
(i) gets( ) - stdio.h
(ii) strcmp( ) - string.h
(iii) abs( ) - math.h, stdlib.h,complex.h
(iv) isalnum( ) - ctype.h
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )