Você está na página 1de 11

KENDRIYA VIDYALAYA SANGATHAN

ERNAKULAM REGION COMPUTER


SCIENCE(083)
SAMPLE QUESTION PAPER-
2012-13
CLASS
XII
TIME: 3 HOURS MAXMARK:
!0
General Instructions- (i) All questions are compulsory
(ii) Programming Language: C++
1 (a) When a function is overloaded, there are multiple definitions of the functions. What makes the
various definitions of the function different from each other?
(b) Which C++ header file(s) will be essentially reuired to run!e"ecute the followin# C++ code?
void main()
$
(%)
(1)
int &no'()*+
char ,-ame./' 012ay 3haskar4+
cout55setw()) 55&no55setw(%*)55,-ame55endl+
6
(c) &ewrite the followin# pro#ram after removin# the syntactical errors (if any). 7nderline each
correction.
8include5iostream.h9
struct ,creen
$ int C, &+6
void ,how:oint(,creen :)
$
(%)
cout55:.C, :.&55endl+
6
void main()
$
,creen :oint1 ' (*, ;)+
,how:oint(:oint1)+
,creen :oint%' point1+
C.:oint1+' %+
:oint1.& ' :oint1.& + %+
6
(d) <ind the output of the followin# pro#ram=
8include5iostream.h9
void Chan#etheContent(int 1rr./, int Count)
$
(;)
for(int C'>+ C5Count+ C++)
1rr.C/' 1rr.Count ? C@ 1/+
6
void main()
$
int 1./' $1, %, ;6, 3./ ' $%>, ;>, (>, *>6, C./' $1>>, %>>6+
Chan#etheContent(1,;)+
Chan#etheContent(3,()+
Chan#etheContent(C,%)+
for(int A'>+ A5;+ A++) cout551.A/55B8B+
cout55endl+
for(int A'>+ A5(+ A++) cout553.A/55B8B+
cout55endl+
for(int A'>+ A5%+ A++) cout55C.A/55B8B+
cout55endl+
6
(e) Cive the output of the followin# pro#ram (1ssumin# that all reuired header files are included in the
pro#ram)
void main()
$
char a./' 0D"am@%>11 1he1d4+
int i+
for(i'>+ a.i/E' FG>B+i++)
$
(%)
if(a.i/9' HI JJ a.i/5'1%%)
a.i/ @@+
else
if(a.i/9' F>B JJ a.i/5' FHB)
a.i/ ' a.i @1/+
else
if(a.i/9' F1B JJ a.i/5' FKB)
a.i/+ ' ;%+
else
6
puts(a)+
6
a.i/' F8B+
(f) ,tudy the followin# pro#ram and select the possible output from it=
8include5iostream.h9
8include5stdlib.h9
const int ALMLN ' (+
void main()
$
(%)
randomiOe()+
int :oints+
:oints' 1>> + random(ALMLN)+
for(int :':oints+ :9'1>>+ :@@)
cout55:55B8B+
cout55endl+
6
(i) 1>;81>%81>181>>8
(ii) 1>>81>181>%81>;8
(iii)1>(81>;81>%81>18
(iv)1>;81>%81>181>>
% (a) What is copy constructor and parameteriOed constructor? Lllustrate with an e"ample. (%)
(b) 1nswer the uestions (i) and (ii) after #oin# throu#h the followin# class=
class mammal$
public=
char cate#ory.%>/+
mammal( char "name./) !! function1
$
(%)
strcpy(cate#ory, "name)
6
mammal(mammal Jt)+ !!function%
6+
(i) Create an ob2ect, such that it invokesfunction1.
(ii) Write complete definition for function%.
(c) Pefine a class ,ports in C++ with followin# descriptions=
:rivate members=
(()
,QCode of type lon#
,Q-ame of type character array (,trin#)
<ees of type inte#er
Puration of type inte#er
:ublic members=
Constructor to assi#n initial values of ,QCode as 1>>1, ,Q-ame as 0Cricket4, <ees as *>>,
Puration I>
1 function -ew,ports() which allows user to enter ,QCode, ,Q-ame and Puration. 1lso
assi#n the values to <ees as per the followin# conditions=
S_Name Fees
Nable Nennis %>>>
,wimmin# (>>>
<ootball ;>>>
1 function Pisplay,ports() to display all the details.
(d) Consider the followin# declarations and answer the uestions #iven below=
class -1NLR-
$
(()
int S+
protected=
int ,+
public=
void L-:7N()+
void R7N:7N()+
6+
class WR&AP= private -1NLR-
$
int N+
protected=
int 7+
public=
void L-P1N1(int, int)+
void R7NP1N1()+
6+
class ,N1ND= public WR&AP
$
int M+
public=
void PL,:A1T(void)+
6+
(i) -ame the base class and derived class of the class WR&AP.
(ii) -ame the data member(s) that can accessed from function PL,:A1T ().
(iii)-ame the member function(s) which can be accessed from the ob2ects of class ,N1ND.
(iv)Ls the member function R7N:7N() accessible by the ob2ects of the class WR&AP.
; (a) Consider the followin# structure=
struct Dmployee
$
(%)
int DCode+
char Dname.%>/+
6+
Write a function to accept an Dmployee array and perform insertion sort in the increasin# order of
DCode.
(b) 1n array M1N.1>.11/ is stored in the memory column wise with each element occupyin# ( bytes of
memory. <ind out the base address and the address of element M1N.*/.1>/, if the location of
M1N.1/.(/ is stored at the address %>>>.
(c) Cive the necessary declaration of a linked list implementation ueue containin# inte#er type elements.
1lso write a user defined function in C++ to delete an inte#er type number from the ueue.
(d) Write a function in C++ to print the sum of all the non@ne#ative elements present on either dia#onal of
a two dimensional array passed as the ar#ument to the function.
(e) Dvaluate the followin# postfi" e"pression usin# a stack and show the contents of the stack after each
operation.
1>>, (>, U, +, %>, 1>, @, +, V
(;)
(()
(;)
(%)
( (a) Rbserve the pro#ram se#ment #iven below carefully and fill the blanks marked in statement 1 usin#
seek#( ) or seekp( ) functions for performin# the reuired task.
8include5fstream.h9
class <LAD
$ int -um+
(1)
char -ame.;>/+
public=
void CRQ&ecord(int)+ 6+ !!function to read -th record from the file
void <LAD==CRQ&ecord(int -)
$
<LAD &ec+ <stream <ile+
<ile.open(0,NRCW4,ios==binaryXios==in)+
!!statement 1
<ile.read((charV)J&ec,siOeof(&ec))+
cout55&ec.-um55&ec.-ame55endl+
<ile.close( )+
6
(b) Write a function to count and print the number of complete words as 0to4 and 0are4 stored in a te"t
file 0D,,1T.NYN4.
void CWR&P,( )
$ ifstream fin(0D,,1T.NYN4)+
char st.U>/+ int
count'>+ while(E
fin.eof())
$ fin99s
t+ if(E
fin)
break+
if(strcmpi(st,4to4) ' '> XX strcmpi(st,4are4)' '>)
count+++
6
cout554GnNotal FtoB J FareB words ' 055count+
fin.close( )+ 6
(c) Write a function in C++ to display ob2ect from the binary file 0:&RP7CN.Pat4 whose product price
is more than &s %>>. 1ssumin# that binary file is containin# the ob2ects of the followin# class=
class :&RP7CN
$
(%)
(;)
int :&RP7CNQno+
char :&RP7CNQname.%>/+
float :&RP7CNQprice+
public=
void enter( )
$
cin99 :&RP7CNQno + #ets(:&RP7CNQname) +
cin 99 :&RP7CNQprice+
6
void display()
$
cout55 :&RP7CNQno + cout55:&RP7CNQname +cout55 :&RP7CNQprice+
6
int retQ:rice( )
$
return :&RP7CNQprice+
6
6+
* (a) What do you understand by the terms 1lternate key and <orei#n Wey of a relation? (%)
Consider the followin# tables ,CSRRA and 1PML-. Write ,ZA commands for the statements (i) to
(iv) and #ive outputs for ,ZA ueries (v) to (viii).
SCHOOL
())
CODE TEACHERNAME SUBJECT DOJ PERIODS EXPERIENCE
1>>1 &1[L ,S1-W1& D-CAL,S 1%!>;!%>>> %( 1>
1>>H :&LT1 &1L :ST,LC, >;!>H!1HHU %) 1%
1%>; AL,1 1-1-P D-CAL,S >H!>(!%>>> %I *
1>(* T1,S&1\ M1NS, %(!>U!%>>> %( 1*
11%; C1-1- :ST,LC, 1)!>I!1HHH %U ;
11)I S1&L,S 3 CSDML,N&T 1H!1>!1HHH %I *
1%1* 7MD,S :ST,LC, 11!>*!1HHU %% 1)
ADMIN
CODE GENDER DESIGNATION
1>>1 M1AD [LCD :&L-CL:1A
1>>H <DM1AD CRR&PL-1NR&
1%>; <DM1AD CRR&PL-1NR&
1>(* M1AD SRP
11%; M1AD ,D-LR& ND1CSD&
11)I M1AD ,D-LR& ND1CSD&
1%1* M1AD SRP
i) No display ND1CSD&-1MD, :D&LRP, of all teachers whose periods less than %*.
ii) No display ND1CSD&-1MD, CRPD and PD,LC-1NLR- from tables ,CSRRA and 1PML-
whose #ender is male.
iii) No display number of teachers in each sub2ect wise.
iv) No display CRPD, ND1CSD&-1MD and ,73\DCN of all teachers who have 2oined the school
after >1!>1!1HHH.
v) ,DADCN M1Y (DY:D&LD-CD), ,73\DCN <&RM ,CSRRA C&R7: 3T ,73\DCN+
vi) ,DADCN ND1CSD&-1MD, CD-PD& <&RM ,CSRRA, 1PML- WSD&D PD,LC-1NLR-
' FCRR&PL-1NR&B 1-P ,CSRRA.CRPD'1PML-.CRPD+
vii) ,DADCN PD,LC-1NLR-, CR7-N (V) <&RM 1PML- C&R7: 3T PD,LC-1NLR-
S1[L-C CR7-N (V) 5%+
viii) ,DADCN CR7-N (PL,NL-CN ,73\DCN) <&RM ,CSRRA+
) (a) [erify X.Y+X.Y=(X+Y).(X+Y) al#ebraically. (%)
(b) Convert the followin# 3oolean e"pression into its euivalent Canonical :roduct of ,um form= (1)
(c) Write the euivalent 3oolean D"pression < for the followin# circuit diagram =
(%)
A B
C
(d) &educe the followin# 3oolean D"pression usin# W@map=
< (Y, T, K, W) ' )
(;)
I (a) Pefine the term 3andwidth. Cive any one unit of 3andwidth. (1)
(b) Pifference between :1- and A1-. (1)
(c) What is iM1:? (1)
(d) Compare [3 ,cript and 1,:. (1)
(e) Dase and West :ublic Atd has decided to network all its offices spread in five buildin# as shown
below=
(()
Building
1
Building 2 Building 3
Building 4
Building 5
Nhe distance between various buildin#s is as follows=
3uildin# 1 to 3uildin# % %>m
3uildin# ; to 3uildin# * I>m
3uildin# % to 3uildin# ; *>m
3uildin# 1 to 3uildin# * )*m
3uildin# ; to 3uildin# ( 1%>m
3uildin# % to 3uildin# * *>m
3uildin# ( to 3uildin# * ;>m
-umber of Computers in each buildin#=
3uildin# 1 (>
3uildin# % (*
3uildin# ; 11>
3uildin# ( )>
3uildin# * I>
(i) ,u##est a cable layout for connectin# all the buildin#s to#ether.
(ii) ,u##est the most suitable buildin# to install the server of the or#aniOation with a suitable
reason.
(iii) 3uildin# ; is used for many critical operations. Lt is tried that :C #ets ma"imum possible
bandwidth. Which network device is!should be used for this?
(iv) Nhe or#aniOation also has another office in same city but at a distant location about%*@;> Wm
away. Sow can link be established with buildin# 1. (,u##est the transmission media).
(f) Pifference between [irus and Nro2an (1)
(#) D"pand <,< and C-7. (1)
***********************