1.e) Find the output of the following program :
#include<iostream.h>
#include<ctype.h>
void Secret(char Msg[ ], int N);
void main( )
{ char SMS[ ]=”rEPorTmE”;
Secret(SMS,2);
cout<<SMS<<endl;
}
void Secret(char Msg[ ], int N)
{ for(int C=0;Msg[C]!=’\0’;C++)
if(C%2= =0)
Msg[C]=Msg[C]+N;
else if(isupper(Msg[C]))
Msg[C]=tolower(Msg[C]);
else
Msg[C]=Msg[C]-N;
}
2
Ans: teRmttoe
1.f) Study the following program and select the possible output from it:
#include<iostream.h>
#include<stdlib.h>
const int MAX=3;
void main( )
{ randomize( );
int Number;
Number=50+random(MAX);
for(int P=Number;P>=50;P--)
cout<<P<<”#”;
cout<<endl;
}(i) 53#52#51#50# (ii) 50#51#52#
(iii) 50#51# (iv) 51#50#
2
Ans: (iv) 51#50#
Solution: MAX value is 3
That’s why random(MAX) can produce 0 or 1 or 2.
(random(N) will produce no. between 1 to n-1)
The Number value may be 50 or 51 or 52.
The P value starts from Number, upto 50,
each time decreases by 1.
So Possible outputs are as follows:
52#51#50#
51#50#
50#
As the output 51#50# is available in given answers, so 51#50# is the answer.)
2008 Delhi:
1.b) Name the header files that shall be needed for the following code:
void main( )
{ char String[ ] = “Peace”;
cout << setw(2)<<String;
}1
Ans) iomanip.h, iostream.h
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )