Important Questions

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

CBSE CLASS XII

2000

Q.1.b. Name the header file, to which following built in function belong. (i) isupper( ) ( ii)setw() (iii)exp( ) (iv)strcmp( )

Ans:

(i) isupper( ) - ctype.h
(ii)setw( ) - iomanip.h
(iii)exp( ) - math.h
(iv)strcmp( ) - string.h

Q.1.c. Will the following program execute successfully?If not, state the eason(s).
#include<stdio.h>
void main( )
{ int s1,s2,num;
s1=s2=0;
for(x=0;x<11;x++)
{ cin<<num;
if(num>0)s1+=num;else s2=/num;
}
cout<<s1<<s2;
}

Ans:

The program will not execute successfully. Because some syntax errors are there in the program. They are
(i)cin and cout, stream objects used but iostream.h header file is not included in the
(ii)x is not declared, it should be declared as
(iii)With cin, we should use >> instead of <<.
(iv)The shorthand operator /=, is given wrongly as =/.
So the corrected program is as follows:
#include<iostream.h>
void main( )
{ int s1,s2,num;
s1=s2=0;
for(int x=0;x<11;x++)
{ cin>>num;
if(num>0)s1+=num;else s2/=num;
}
cout<<s1<<s2;
}

d. Give the output of the following program
segment(Assuming all required header files
are included in the program): 2
char *NAME=”a ProFiLe”;
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-1]);
else
NAME[x]--;
cout<<NAME<<endl;

Ans:

Output: AOROoIiE

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