Important Questions

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

CBSE CLASS XII

2004 Annual Paper.

Q.1.b. Write the names of the header files to (i) gets( ) (ii) strcmp( ) (iii)abs( ) (iv)isalnum( )

Ans:

(i)gets( ) - stdio.h
(ii)strcmp( ) - string.h
(iii)abs( ) - math.h, stdlib.h,complex.h
(iv)isalnum( ) - ctype.h

Q.1.e. What will be the output of the following.
#include<iostream.h>
void main( )
{ int var1=5,var2=10;
for(int i=1,i<=2;i++)
{ cout<<var1++<<’\t’<< - - var2<<endl;
cout<<var2- -<<’\t’<<+ + var1<<endl;
}
}

Ans:

Output:
5 9
9 7
7 7
7 9

Q1.f. Write definition for a function SumSequence( ) in C++ with two arguments/ parameters – double X and int n. The function should return a value of type double and it should perform sum of the following series. 1/x- 3!/x2 + 5!/x3 – 7!/x4 + 9!/x5 - ------upto n terms.
Note: The symbol ! represents Factorial of a number ie 5!= 1 X 2 X 3 X 4 X 5.
#include<iostream.h>
#include<math.h>
#include<conio.h>
double SumSequence(int x1,int n1);
void main()
{ int x;
int n;
clrscr();
cout<<"Enter the vaue of X and N";
cin>>x>>n;
cout<<”\nThe sum of the series =
“<<SumSequence(x,n);
getch();
}
double SumSequence(int x1,int n1)
{ double sum=0;
int c=0;
for(int i=1;i<=(2*n1);i=i+2)
{ int f=1;
for(int j=1;j<=i;j++)
{ f=f*j;
}
c=c+1;
if(c%2==1)
{ sum=sum+f/(pow(x1,c));
}
else
{ sum=sum-f/(pow(x1,c));
}
}
return sum;
}

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