CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By MRK
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
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.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;
}
1.f. Write a C++ function having two value parameters X and N with result type float to find the sum of series given below:
1 + x1/2! + x2/3! + x3/4! + x4/5! + - - - - - - xn/(n+1)!
#include<iostream.h>
#include<conio.h>
#include<math.h>
float sum_series(float X,int N) //function being declared
{ float sum=0,term;
int fact,f;
sum+=1;
for(int i=1;i<=N;i++)
{ fact=1;
for(f=1;f<=(i+1);f++)
fact*=f;
term=pow(X,i)/fact;
sum+=term;
}
return(sum);
}
void main( )
{ clrscr( );
float x1;
int n1;
cout<<"\nEnter the value of X and N";
cin>>x1>>n1;
cout<<"\nThe Sum of the Series
..."<<sum_series(x1,n1);
getch()
Paper By Mr. MRK
Email Id : [email protected]@yahoo.com |