CBSE Sample Paper – 2010
Class – XII
Computer Science
Instructions:
i) All questions are compulsory.
ii) Please write down the complete serial number of the question before attempting it.
1. a) Write the names of the header files to which the following belong : 2
(i) random( ) (ii) fmod( ) (iii)floodfill() (iv) gotoxy()
b) Name the header files to execute the following program: 2
void main ()
{
char name[20];
char ch;
strcpy(name, "I Revision 2009");
randomize();
clrscr();
ch = name[11+random(0)];
while (!isalpha(ch) )
{
if (isdigit (ch))
{
cout << setw(10) << int(ch);
}
ch = name[random(0)];
}
getch();
}
c) Rewrite the following program after removing syntactical error(s) if any. Underline each correction. 2
#include<iostream.h>
#define SIZE =10
VOID Main()
{
int a[SIZE]={1,2,3,4,5};
float x=2;
SIZE=5;
for(int i=0;i<SIZE;i++)
cout<<a[i]%x;
}
d) What are the first and last values of i output by this loop? 2
n = 10;
i = 0;
while (++i < n)
{ cout<<i<<endl; }
e) Differentiate between Local and Global variable with example. 2
2. a) Define a class ELECTION with the following specifications. Write a suitable main ( ) function also to declare 3 objects of ELECTION type and find the winner and display the details. 3
Private members:
Data : candidate_name, party, vote_received
Public members:
Functions : enterdetails ( ) – to input data
Display ( ) – to display the details of the winner
Winner ( ) – To return the details of the winner through the object after comparing the votes received by three candidates.
b) What do you mean by static data members of a class? Explain the characteristics of a static data member. 2
c) Find the Output of the following - 2
class alpha {
static int count;
public:
alpha() {
count++;
cout<<”n No. of object created”<<count; }
~alpha() {
cout<<”
No. of object destroyed”<<count;
count--; }
};
int alpha:: count=0;
void main() {
cout<<”
ENTER MAIN
”;
alpha A1,A2,A3,A4;
{cout<<”
ENTER BLOCK 1
”;
alpha A5;}
{
cout<<”
ENTER BLOCK 2
”;
alpha A6;
}
cout<<”
RE-ENTER MAIN
”;
}
d) Consider the following declarations and answer the questions given below: 3
class Mydata
{ protected:
int data;
public:
void Get_mydata(int);
void Manip_mydata(int);
void Show_mydata(int);
Mydata( );
~Mydata( ); };
class Personal_data
{
protected:
int data1;
public:
void Get_personaldata(int);
void Show_personaldata(int);
Mydata1( );
~Mydata1( ); };
class Person: public Mydata, Personal_data
{
public:
void Show_person(void);
person( );
~person( ); };
i) How many bytes will be required by an object belonging to class Person?
ii) Which type of inheritance is depicted in the above example?
iii) List the data members that can be accessed by the member function Show_person( )
iv) What is the order of constructor execution at the time of creating an object of class Person?
----------Please Go To Next Page------------