Professional Documents
Culture Documents
12 Computer Science Lyp 2017 Outside Delhi Set 4 PDF
12 Computer Science Lyp 2017 Outside Delhi Set 4 PDF
General Instructions :
SECTION A
[Only for candidates, who opted for C++]
1. (a) Write the type of C++ tokens (keywords and user defined identifiers) from the
following: (2)
(i) new (ii) While (iii) case (iv) Num_2
Ans. (i) new - Keyword (ii) While - User defined Identifier
(iii) case - Keyword (iv) Num_2 - User defined Identifier
(b) Anil typed the following C++ code and during compilation he found three errors as
follows:
(i) Function strlen should have prototype (ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code. Write the
names of the header files, which Anil needs to include, for successful compilation and
execution of the following code: (1)
void main( )
{
char Txt [ ] = "Welcome";
for (int C= 0; C<strlen(Txt); C++)
Txt[C] = Txt[C]+1;
void main ( )
{
randomize ( );
int N=random(3),M=random(4);
int DOCK[3][3] = {{1,2,3},{2,3,4},{3,4,5}};
for(int R=0; R<N; R++)
{
for (int C=0; C<M; C++)
cout<<DOCK[R][C]<<" ";
cout<<endl;
}
}
(i) (ii)
1 2 3
1 2 3
2 3 4
2 3 4
3 4 5
(iii) (iv)
1 2
1 2
2 3
2 3
3 4
Example:
Class A
{
Int X;
protected:
int Y;
public:
void Z ( );
};
OR Any other correct example demonstrating difference between private and
protected members of a class
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.
class TEST
{
long TCode;
char TTitle[20];
float Score;
public:
TEST() //Member Function 1
{
TCode=100;strcpy(TTitle,"FIRST Test");Score=0;
}
TEST(TEST &T) //Member Function 2
{
TCode=E.TCode+1;
strcpy(TTitle,T.TTitle);
Score=T.Score;
23 30 45 10 15 25
53 40 55 20 40 35
Note :
The function should only alter the content in the same array.
The function should not copy the altered content in another array.
The function should not display the altered content of the array.
Assuming, the Number of elements in the array are Even.
1 2 1
2 1 4
3 4 5
4 5 3
5 3 2
The function should calculate the sum and display the following : Sum of Middle Column: 15
Ans. void SUMMIDCOL(int MATRIX[][10],int N,int M)
{
int mid=M/2;
int sum=0;
for(int i=0; i<N; i++)
{
sum=sum+MATRIX[i][mid];
} c
out<<” Sum of Middle Column”<<sum;
} O
R
Any other correct C++ code for the required function definition
(c) ARR[15][20] is a two-dimensional array, which is stored in the memory along the
row with each of its elements occupying 4 bytes.
Find the address of the element ARR[5][15], if the element ARR[10][5] is stored at the
memory location 35000. (3)
Ans. ROW MAJOR:
Loc(ARR[I][J]) =BaseAddress + W [( I – LBR)*C + (J – LBC)]
(where W=size of each element = 4 bytes, R=Number of
Rows=15, C=Number of Columns=20 )
Assuming LBR = LBC = 0
LOC(ARR[10][5])
35000 = BaseAddress + W(I*C + J)
X X
- - X
( -( X
Y -( XY
+ -(+ XY
Z -(+ XYZ
) - XYZ+
/ -/ XYZ+
U -/ XYZ+U
V -* XYZ+U/V
XYZ+U/V*-
OR
X-(Y+A)/U*V = (X-(((Y+Z)/U) *V))
X X
- -
Y XY
+ -+
Z XYZ
) - XYZ+
/ -/
U XYZ+U
) - XYZ+U/
* -*
V XYZ+U/V
) XYZ+U/V*
) XYZ+U/V*-
Postfix= XYZ+U/V*-
OR Any other method for converting the given infix expression to its equivalent postfix
SECTION B
[Only for candidates, who opted for Python]
1. (a) Which of the following can be used as valid variable identifier(s) in Python? (2)
(i) 4thSum (ii) Total (iii) Number# (iv) _Data
Def_init_(self, B, S, A):
#Any variable instead of B, S, A, may be used
Self.Box=B
Self.Side=S
Self.Side=A
def __init__(self):
self.BoxID=101
self.Side=10
self.Area=0
def ExecArea(self):
self.Area=self.Side*self.Side
def NewBox(self):
self.BoxID=input("Enter BoxID")
self.Side=input("Enter side")
self.ExecArea ( ) # OR ExecArea(self)
def viewBox (self):
52 42 -10 60 90 20
42 52 -10 60 90 20
42 -10 52 60 90 20
42 -10 52 60 90 20
42 -10 52 60 20 90
II Pass
42 -10 52 60 20 90
-10 42 52 60 20 90
-10 42 52 60 20 90
-10 42 52 60 20 90
-10 42 52 20 60 90
III Pass
-10 42 52 20 60 90
-10 42 52 20 60 90
-10 42 52 20 60 90
-10 42 20 52 60 90
(b) Write definition of a method EvenSum(NUMBERS) to add those values in the list of
NUMBERS, which are odd. (3)
Ans. def EvenSum(NUMBERS):
n=len(NUMBERS)
s=0
for i in range(n):
if (i%2!=0):
s=s+NUMBERS[i]
p
(c) Write Addnew(Member) and Remove(Member) methods in Python to Add a new
Member and Remove a Member from a list of Members, considering them to act as
4 4
2 4, 2
22 8, 22
5 8, 22, 5, 6
6 8, 22, 5, 6
+ 8, 22, 11
/ 8, 2
- 6
Answer: 6
4. (a) Differentiate between file modes r+ and rb+ with respect to Python. (1)
Ans. r+ Opens a file for both reading and writing. The file pointer placed at the beginning of
the file.
rb+ Opens a file for both reading and writing in binary format. The file pointer placed at the
beginning of the file.
(b) Write a method in Python to read lines from a text file MYNOTES.TXT, and display
those lines, which are starting with the alphabet ―K‖. (2)
Ans. def display ( ):
file=open('MYNOTES.TXT','r')
line=file.readline ( )
while line:
if line[0]=='K' :
print line
line=file.readline ( )
file.close ( ) #IGNORE
(c) Considering the following definition of class FACTORY, write a method in Python to
search and display the content in a pickled file FACTORY.DAT, where FCTID is matching
with the value ―’105’. (3)
class Factory:
def __in it__(self, FID, FNAM):
self. FCTID = FID # FCTID Factory ID
self. FCTNM = FNAM # FCTNM Factory Name
SECTION C
[For all the candidates]
5. (a) Observe the following table MEMBER carefully and write the name of the RDBMS
operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT,
which has been used to produce the output as shown in RESULT. Also, find the Degree
and
Cardinality of the RESULT: (2)
MEMBER
NO MNAME STREAM
RESULT
DVD
MEMBER
(i) To display all details from the table MEMBER in descending order of ISSUEDATE.
Ans. SELECT * FROM MEMBER ORDER BY ISSUEDATE DESC;
(ii) To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD.
Ans. SELECT DCODE,DTITLE FROM DVD WHERE DTYPE=’Folk’;
(iii) To display the DTYPE and number of DVDs in each DTYPE from the table DVD.
Ans. SELECT COUNT(*),DTYPE FROM DVD GROUP BY DTYPE;
(iv) To display all NAME and ISSUEDATE of those members from the table MEMBER
(b) Draw the Logic Circuit of following Boolean Expression using only NOR Gates: (2)
(A+B).(C+D)
Ans.
(c) Derive a Canonical POS expression for a Boolean function G, represented by the
following truth table: (1)
X Y Z G(X,Y,Z)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 1 1
OR
E(U,V,Z,W)=UZ’+V’Z+U’ZW’
7. (a) Differentiate between communication using Optical Fiber and Ethernet Cable in
context of wired medium of communication technologies. (2)
Ans. - Optical Fibre
- Very Fast - Expensive - Immune to electromagnetic interference
Ethernet Cable -
- Slower as compared to Optical Fiber - Less Expensive as compared to Optical Fiber
- prone to electromagnetic interference
(b) Janish Khanna used a pen drive to copy files from his friend‖s laptop to his office
computer. Soon his computer started abnormal functioning. Sometimes it would
(i) Suggest the most appropriate block/location to house the SERVER in the CHENNAI
office (out of the 3 blocks) to get the best and effective connectivity. Justify your
answer. (1)
Ans. Training Block - Because it has maximum number of computers.
(ii) Suggest the best wired medium and draw the cable layout (Block to Block) to
efficiently connect various blocks within the CHENNAI office compound. (1)
Ans. Best wired medium: Optical Fibre OR CAT5 OR CAT6 OR CAT7 OR CAT8 OR Ethernet
Cable
(iii) Suggest a device/software and its placement that would provide data security for
the entire network of the CHENNAI office. (1)
Ans. Firewall - Placed with the server at the Training Block OR Any other valid device/
software name
(iv) Suggest a device and the protocol that shall be needed to provide wireless Internet
access to all smartphone/laptop users in the CHENNAI office. (1)
Ans. Device Name: WiFi Router OR WiMax OR RF Router OR Wireless Modem OR RF
Transmitter