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

1998 Annual Paper:
1.b. Name the header files, to which the following built in functions belongs to:
- cos( )
- setw( )
- toupper( )
- strcpy( )
Ans:
- cos( ) - math.h
- setw( ) - iomanip.h
- toupper( ) - ctype.h
- strcpy( ) - string.h
1.c. Find the syntax error(s), if any, in the following program:
include<iostream.h>
void main( )
int R; W=90;
{
while W>60
{
R=W-50; switch(W)
{
20:cout<<”Lower Range”<<endl;
30:cout<<”Middle Range “<<endl;
40:cout<<”Higher Range”<<endl;
}
}
}
Ans:
- Line 1: It should be, # include<iostream.h>
- Line 4:Variables should be separated using commas. It should be int R,W=90;
- Line 5:Test expression should be in braces. It should be while (W>60)
- Line 10:It should be case 20;
- Line 11:It should be case 30;
- Line 13:It should be case 40;
So the corrected version of the program is as follows:
#include<iostream.h>
void main( )
{
int R, W=90; while (W>60)
{
R=W-50; switch(W)
{
case 20:cout<<”Lower Range”<<endl;
case 30:cout<<”Middle Range “<<endl;
case 40:cout<<”Higher Range”<<endl;
}
}
}
1.d. Give the output of the following program segment:
char *NAME=”IntRAneT”;
for(int x=0;x<strlen(NAME); x++)
if(islower(NAME[x])
NAME[x]=toupper(NAME[x]));
else if(isupper(NAME[x]))
if(x%2==0)
NAME[x]=tolower
(NAME[x]);
else
NAME[x]=NAME[x-1]; puts(NAME);
Ans: Output: INTTaNEE
1.e. Write the output of the following program:
#include<iostream.h>
void Execute(int &X,int Y=200)
{
int TEMP=X+Y; X+=TEMP;
if(Y!=200) cout<<TEMP<<X<<Y<<endl;
} void main( )
{
int A=50,B=20; Execute(B);
cout<<A<<B<<endl;
Execute(A,B);
cout<<A<<B<<endl;
}

Computer Science By Mr. MRK
|