Sample Paper - 2009 Class - XII Subject - COMPUTER SCIENCE (083) Time: 3 Hrs Max - Marks:70 Q.1)
Sample Paper - 2009 Class - XII Subject - COMPUTER SCIENCE (083) Time: 3 Hrs Max - Marks:70 Q.1)
com/
void main( )
{ randomize( );
int Disp,Rnd;
Cin>>Disp;
Rnd=random(Disp)+15;
for(int N=1,i=3;i<=Rnd; i+=4,N++)
cout<<N<<” “;
}
Output Options:
(i) 1 (ii) 1 2 3 4
(iii) 1 2 (iv) 1 2 3
(g) Find the output of the following program: (2)
#include<iostream.h>
#include<string.h>
class State
{
char *state_name;
int size;
public:
State( ){size=0;state_name=new char [size+1];}
State(char *s)
{ size=strlen(s);
state_name=new char[size+1];
strcpy(state_name,s);
}
void display( )
{ cout<<state_name<<endl;
}
void Replace(state &a, state &b)
{ size=a.size+b.size;
delete state_name;
state_name=new char[size+1];
strcpy(state_name, a.state_name);
strcat(state_name, b.state_name);
}
};
void main( )
{
char *temp=”Calcutta”;
State state1(temp),state2(“Hyderabad”),state3(“Chennai”),S1,S2;
S1.Replace(state1,state2);
S2.Replace(S1,State3);
S1.display( );
S2.display ( );
S2.Replace(state2,state3);
S2.display( );
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
}
Q2)
(a) Explain about virtual base class using a suitable example. (2)
(b) Answer the questions (i) and (ii) after going through the following program: (2)
class Date
{ int day,month,year;
public:
Date(Date &D); //Constructor 1
Date(int a,int b,int c) //Constructor 2
{ day=a;
month=b;
year = c;
}
};
(i) Write complete definition for Constructor 1
(ii) Create an object, such that it invokes Constructor 2
(c) Define a class PhoneBill in C++ with the following descriptions. (4)
Private members:
CustomerName of type character array
PhoneNumber of type long
No_of_units of type int
Rent of type int
Amount of type float.
calculate( ) This member function should calculate the value of amount as
Rent+ cost for the units.
Where cost for the units can be calculated according to the following conditions.
No_of_units Cost
First 50 calls Free
Next 100 calls 0.80 @ unit
Next 200 calls 1.00 @ unit
Remaining calls 1.20 @ unit
Public members:
* A constructor to assign initial values of CustomerName as “Raju”, PhoneNumber as
259461, No_of_units as 50, Rent as 100, Amount as 100.
* A function accept( ) which allows user to enter CustomerName, PhoneNumber,No_of_units
And Rent and should call function calculate( ).
* A function Display( ) to display the values of all the data members on the screen.
2.d) Answer the questions (i) to (iv) based on the following code: (4)
class Teacher
{
char TNo[7],TName[25],Dept[12];
int Wload;
protected:
double Sal;
void AssignSal(double);
public:
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
Teacher( );
Teacher(Double S);
void TeaNew( );
void TeaDisplay( );
};
class Student
{
char ANo[6],SName[15],Group[7];
protected:
int Att,Total;
public:
Student( );
void StuAccept( );
void StuDisplay( );
};
class School: public Student, private Teacher
{
char SchCode[9],SchName[15];
public:
School( );
void SchAccept( );
void SchDisplay( );
};
(i) How many bytes will be reserved for an object of type School?
(ii) Name the members that can be called by object of type School.
(iii)Which type of inheritance is depicted by the above example?
(iv) Identify the member function(s) that cannot be called directly from the objects of class School
from the following: (a) TeaNew( ) (b) StuAccept( ) (c) SchDisplay( ) (d)AssignSal( )
Q3)
(a) Suppose A,B,C are arrays of size m,n,m+n respectively. Array A is stored in ascending order
and array B is in descending order. Write a function to receive 3 arrays and their sizes to store the
elements of A and B into C in descending order. (3)
(b)An array Arr[35][15] is stored in the memory along the row with each of its element occupying
4 bytes. Find out the base address and the address of an element Arr[20][5], if the location Arr[2]
[2] is stored at the address 3000. (4)
(c)Write a function in C++ which accepts an integer array and its size as arguments/parameters and
assign the elements into a two dimensional array of integers in the following format
(size must be odd) (3)
If the array is 1 2 3 4 5 If the array is 10 15 20
The output must be The output must be
10005 10 0 20
02040 0 15 0
00300 10 0 20
02040
10005
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
(d) Write a function in C++ to delete a node containing city’s information (ie city name and its
population) from a dynamically allocated Queue of cities. (4)
(e) Evaluate the following postfix notation of expression (show the position of stack) (2)
25 11 2 % * 5 -
Q4)
(a) Observe the program segment given below carefully , and answer the question that follows(1)
class Member
{ int Member_no ;
char Member_name[20] ;
public :
void enterdetails ( ) ; //function to enter Member details
void showdetails ( ) ; //function to display Member details
int RMember_no( ) //function to return Member_no
{return Member_no ;}
};
void Update (Member NEW)
{ fstream File ;
File.open(“MEMBER.DAT” , ios :: binary l ios :: in l ios :: out) ;
Member OM ;
int Recordsread = 0, Found = 0 ;
while (!Found && File.read((char*) & OM, sizeof(OM)))
{ Recordsread++ ;
if (NEW.RMember_no( ) == OM.RMember_no( ))
{ _____________ // Statement 1
_____________ // Statement 2
Found = 1 ;
}
else
File.write((char*) & OM, sizeof(OM)) ;
}
if (!Found)
cout<<”Record for modification does not exist” ;
File.close( ) ;
}
If the function Update( ) is supposed to modify a record in file MEMBER.DAT with the values of
Member NEW passed to its argument, write the appropriate statements for statement1using seekp( )
or seekg( ) whichever needed, statement 2 using read( ) or write( ) method, whichever needed in
the above code that would write the modified record at its proper place.
(b)Assuming that a text file named FIRST.TXT contains some text written into it, write a function
named vowelwords( ), that reads the file FIRST.TXT and creates a new file named SECOND.TXT,
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
to contain only those words from the file FIRST.TXT which start with start with a lowercase vowel
(i.e. with ‘a’, ’e’, ’I’, ‘o’, ‘u’). (3)
For example if the file FIRST.TXT contains
Carry umbrella and overcoat when it rains
Then the file SECOND.TXT shall contain:
umbrella and overcoat it
(c)Given a binary file STUDENT.DAT contains the records of the following structure type: (2)
struct Student
{ int rno;
float m1,m2,m3;
};
Write a function in C++ that would read contents from the file STUDENT.DAT and modify the
marks to 35 if anybody’s any marks are less than 35.
Q.5)
(a) Differentiate between DDL and DML. Mention the 2 commands for each caterogy. (2)
(b) Write the SQL commands for (i) to (iv) and outputs for (v) to (viii) on the basis of tables
BOOKS and ISSUES.(4 X 1 + 4 X 0.5) (6)
Table: BOOKS
Book_ID BookName AuthorName Publisher Price Qty
L01 Maths Raman ABC 70 20
L02 Science Agarkar DEF 90 15
L03 Social Suresh XYZ 85 30
L04 Computer Sumita ABC 75 7
L05 Telugu Nannayya DEF 60 25
L06 English Wordsworth DEF 55 12
Table: ISSUES
Book_ID Qty_Issued
L02 13
L04 5
L05 21
(i) To show Book name, Author name and Price of books of ABC publisher.
(ii) To display the details of the books in descending order of their price.
(iii) To decrease the Qty_Issued from ISSUES table by 3 (all rows must decrease).
(iv) To display the Book Id, Book name, Publisher, Price, Qty, Qty_Issued from both the tables
with their matching Book ID.
(v) SELECT sum(price) FROM Books WHERE Publisher = “DEF”;
(vi)SELECT Publisher, min(price) FROM Books GROUP BY Publisher;
(vii)SELECT Price from Books, Issues where Books.Book_ID=Issues.Book_ID AND Qty_Issued=5;
(viii)SELECT Count(Distinct Publisher) FROM Books;
Q6)
(a) State and prove Demorgan’s laws. (2)
(b) Write the equivalent Boolean expression for the following logic circuit. (1)
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com
http://www.cbseguess.com/
(i) Suggest a possible cable layout for connecting the buildings. (1)
(ii)Suggest the most suitable place to install the server of this organization with a suitable reason(1)
(iii) Suggest the placement of the following devices with justification. (1)
(a) Hub/Switch (b) Modem
(iv) The Bank wans to link its head Office in ‘A’ building to its main office at Mumbai. (1)
(a) Which type of transmission medium is appropriate for such a link?
(b) What type of network this connection result into?
-------------------------------------------------------------------------------------------------------
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com