Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

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

Q.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

Paper By Mr. Ravi Kiran
Email Id : [email protected]