1998 Annual Paper:
1.b) Name the header files, to which the following built in functions belongs to: (i)cos( )(ii)setw( )(iii)toupper( )(iv)strcpy( )
Ans:
(i) cos( ) - math.h
(ii) setw( ) - iomanip.h
(iii) toupper( ) - ctype.h
(iv) 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:
(i) Line 1: It should be, #include<iostream.h>
(ii) Line 4:Variables should be separated using commas. It should be int R,W=90;
(iii) Line 5:Test expression should be in braces. It should be while (W>60)
(iv) Line 10:It should be case 20;
(v) Line 11:It should be case 30;
(vi) 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.f) 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;
}
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )