Important Questions

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 func(int &x,int y=10)
{ if(x%y==0) return ++x;else return y- -;
}
void main( )
{ int p=20,q=23;
q=func(p,q);
cout<<p<<q<<endl;
p=func(q);
cout<<p<<q<<endl;
q=func(p);
cout<<p<<q<<endl;
}

Ans:

Output. 2023
1023
1111

f. Write a function seqsum( ) in C++ with two arguments, double x and int n. The function should return a value of type double and it should find the sum of the following series.
1+ x/2! + x2/4! + x3/6! + x4/8! + x5/10! + ----+ xn/(2n)!
#include<iostream.h>
#include<math.h>
#include<conio.h>
double seqsum(int x1,int m1);
void main()
{ int x;
int m;
clrscr();
cout<<"Enter the vaue of X and M";
cin>>x>>m;
cout<<"\nThe sum of the series =
"<<seqsum(x,m);
getch();
}
double seqsum(int x1,int m1)
{ double sum=1;
for(int i=1;i<=m1;i++)
{ int f=1;
for(int j=1;j<=2*i;j++)
{ f=f*j;
}
sum=sum+pow(x1,i)/f;
}
return sum;
}

1999 Annual Paper

Q.1.a. Why main( ) function is so special. Give two reasons?

Ans:

Execution of the program starts and ends at main( ). The main( ) is the driver function of the program. If it is not present in a program, no execution can take place.

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