Important Questions

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

CBSE CLASS XII

f. Write a C++ function SUMFUN( ) having two parameters Y(of type double) and m(of type integer) with a result type as double to find the sum of the series given below:
Y + Y3 / 2! + Y5 /3! + ------ + Y 2m-1 / m!
#include<iostream.h>
#include<math.h>
#include<conio.h>
double SUMFUN(int y1,int m1);
void main()
{ int y;
int m;
clrscr();
cout<<"Enter the vaue of Y and M";
cin>>y>>m;
cout<<”\nThe sum of the series =
“<<SUMFUN(y,m);
getch();
}
double SUMFUN(int y1,int m1)
{ double sum=0;
double upper;
for(int i=1;i<=m1;i++)
{ int f=1;
for(int j=1;j<=i;j++)
{ f=f*j;
}
upper=pow(y1,(i*2-1));
sum=sum+upper/f;
}
return sum;
}

2002

1.b. Name the header files of C++ to which the following functions belong:2
(i)get( ) (ii)open( ) (iii)abs( ) (iv)strcat( )

Ans: (i)get( ) - iostream.h
(ii)open( ) - fstream.h
(iii)abs( ) - math.h, stdlib.h
(iv)strcat( ) - string.h

1.c. Find the syntax error(s), if any, in the following program. 2
#include<iostream.h>
void main( )
{ int x;
cin>>x;
for( int y=0,y<10,y++)
cout<<x+y;
}

Ans
#include<iostream.h>
void main( )
{ int x;
cin>>x;
for( int y=0;y<10;y++)
cout<<x+y;
}

1.d. Write the output of the following program2
void main( )
{ int x=5,y=5;
cout<<x- -;
cout<<”,”;
cout<- - x;
cout<<”,”;
cout<<y- -<<”,”<<- -y;
}

Ans. Output:
5,3,4,4

1.e. Write the output of the following program3
#include<iostream.h>
void X(int &A,int &B)
{ A=A+B;
B=A-B;
A=A-B;
}
void main( )
{ int a=4,b=18;
X(a,b);
cout<<a<<”,”<<b;
}

Ans. Output:
18,4

Paper By Mr. MRK
Email Id : [email protected]@yahoo.com