CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran
CBSE CLASS XII
Q.1.e. Write the output of the following program.
#include<iostream.h>
int Execute(int M)
{ if(M%3==0)
return M*3;
else
return M+10;
}
void Output(int B=2)
{ for(int T=0;T<B;T++)
cout<<Execute(T)<<”*”;
cout<<endl;
}
void main( )
{ Output(4);
Output( );
Output(3);
}
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
Q.1.b. Name the header files of C++ to which the
following functions belong.
(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
Paper By Mr. Ravi Kiran
Email Id : [email protected] |