CBSE eBooks

CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK

Chapter – 1 C++ Revision Tour

Previous Index Next

1.d. Find the output of the following program: 3

#include<iostream.h>
#include<ctype.h>
void main( )
{
char Mystring[ ] = "what@OUTPUT!";
for(int I=0; Mystring[I]!='\0';I++)
{
if(!isalpha(Mystring[I]))
Mystring[I]='*';
else if(isupper(Mystring[I]))
Mystring[I]=Mystring[I]+1;
else
Mystring[I] =Mystring[I+1];
}
cout<<Mystring;
}

Ans: Output: hat@*PVUQVU*

1. e. Find the output of the following program: 2

#include<iostream.h>

void main( )
{
int A=5,B=10;
for(int I=1;I<=2;I++)
{
cout<<”Line1”<<A++<<”&”<<B-2 <<endl;
cout<<”Line2”<<++B<<”&”<<A +3 <<endl;
}
}

Ans: Output:

Line15&8
Line211&9
Line16&9
Line212&10

1. f. In the following program, find the correct possible output(s)
from the options: 2

#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize( );
char Area[ ][10]={“NORTH”,”SOUTH”,”EAST”,”WEST”};
int ToGo;
for(int I=0; I<3;I++)
{
ToGo=random(2) + 1;
cout<<Area[ToGo]<<”:”;
}
}

Previous Index Next