91 (Comp. Sci)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

SET – 4

Series : GBM/C Code No. 91


Candidates must write the Code on
Roll No. the title page of the answer-book.

• Please check that this question paper contains 16 printed pages.


• Code number given on the right hand side of the question paper should be written on the
title page of the answer-book by the candidate.
• Please check that this question paper contains 7 questions.
• Please write down the Serial Number of the question before attempting it.
• 15 minute time has been allotted to read this question paper. The question paper will be
distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the students will read the
question paper only and will not write any answer on the answer-book during this period.

COMPUTER SCIENCE
Time allowed : 3 hours Maximum marks : 70

General Instructions :
(i) SECTION A refers to programming language C++.
(ii) SECTION B refers to programming language Python.
(iii) SECTION C is compulsory for all.
(iv) Answer either SECTION A or SECTION B.
(v) It is compulsory to mention on the page 1 in the answer book whether you are
attempting SECTION A or SECTION B.
(vi) All questions are compulsory within each section.

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) case
(ii) _delete
(iii) WHILE
(iv) 21stName
91 1 [P.T.O.
(b) Jayneel has just started learning C++. He typed the following C++ code and during
the compilation of the code, he got some errors. When Jayneel asked his teacher,
the teacher told him to include necessary header files in the code. 1
Write the names of those header files, which Jayneel needs to include, for
successful compilation and execution of the following code.
void main()
{
cout <<"We win !"<<endl;
cout <<strlen("The World")<<endl ;
}
(c) Rewrite the following C++ code after removing any/all syntactical errors with each
correction underlined. 2
Note : Assume all header files required in the code are already being included.
#define 10*Number MAX(Number)
void main()
{
int Num,NewNum;
cout<<"Number:";
cin<<Num;
if Num<10
NewNum=MAX(Num);
else
NewNum=Num-2;
cout<<"New Number:"<<NewNum<<end;
}
(d) Find and write the output of the following C++ program code : 2
Note : Assume all required header files are already included in the program.
void Decider(int &K,int L=70)
{
if (K>L)
K-=L;
else
K+=L;
}
void main()
{

91 2
int M=100,N=40;
Decider(M,N);
cout<<M<<"#"<<N<<endl;
Decider(M);
cout<<N<<"#"<<M<<endl;
}
(e) Find and write the output of the following C++ program code : 3
Note : Assume all required header files are already being included in the program.
void DispScore(int S[],int N)
{
for(int Count = 0;Count<N;Count++)
cout<<S[Count]<<"#";
cout<<endl;
}
void main()
{
int *Point,Score[]={10,5,20,15};
Point=Score;
DispScore(Score,2);
for(int Count=0; Count<4; Count++)
{
cout<<*Point<<":";
if(Count%2==0)
Point++;
else
{
*Point +=10;
Point++;
}
}
cout<<endl;
DispScore(Score,4);
}
(f) Look at the following C++ code and find the possible output(s) from the options
(i) to (iv) following it. Also, write the maximum values that can be assigned to each
of the variables Low and High. 2
Note :
• Assume all the required header files are already being included in the code.
• The function random(n) generates an integer between 0 and n – 1.
91 3 [P.T.O.
void main()
{
randomize();
int Low=2+random(3),High=5+random(3);
int C[] = "ABCDEFGHIJ";

for(int I=Low;I<=High;I++)
cout<<C[I];
cout<<endl;
}
(i) (ii)
BCDE CDEF
(iii) (iv)
CDE DCEFG
2. (a) Differentiate between Data Hiding and Data Encapsulation in context of Object
Oriented Programming. Also give a suitable example illustrating the same in C++. 2
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.
class GAME
{
int Pcode,Round,Score;
public:
GAME() //Member Function 1
{
Pcode=1;Round=0;Score=0;
}
GAME(GAME &G) //Member Function 2
{
Pcode=G.Pcode+1;
Round=G.Round+2;
Score=G.Score+10;
}
};
void main()
{
_____________ //Statement 1
_____________ //Statement 2
}

91 4
(i) Which Object Oriented Programming feature is illustrated by the Member
Function 1 and Member Function 2 together in the class GAME ? 1
(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and
Member Function 2 respectively. 1
(c) Write the definition of a class FRAME in C++ with following description : 4
Private Members
- FID // data member of integer type
- Height // data member of float type
- Width // data member of float type
- Amount // data member of float type
- GetAmount() // Member function to calculate and assign
// Amount as 10∗ ∗Height∗ ∗Width
Public Members
- GetDetail() // A function to allow user to enter values of
// FID, Height, Width. This Function should
// also call GetAmount() function to calculate
// Amount

- DispDetail() // A function to display the


// values of all data members
(d) Answer the questions (i) to (iv) based on the following : 4
class DIGITAL
{
int ID;
protected:
float Amount;
int Seconds;
public:
DIGITAL();
void Register(); void Disp();
};
class PRINT
{
int PID;
protected:
float Amount;
int SQinch;
public:
PRINT();
void Get();
void Print();
};

class MEDIA : Public PRINT, private DIGITAL


{
int MID;

91 5 [P.T.O.
public:
MEDIA();
void Enter();
void Print();
};
void main()
{
MEDIA M; //Statement 1
__________; //Statement 2
}
(i) Which type of Inheritance out of the following is illustrated in the above
example ?
– Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the member functions, which are directly accessible by
the object M of class MEDIA as declared in main( ) function.
(iii) What will be the order of execution of the constructors, when the object M of
class MEDIA is declared inside main ( ) ?
(iv) Write Statement 2 to call function Print( ) of class PRINT from the object M
of class MEDIA.

3. (a) Write the definition of a function MIXER(int A[], int N) in C++, which should
multiply 2 to the odd values present in the array and multiply 3 to the even values
present in the array. The entire content of the array A having N elements should
change without using any other array. 2
Example : if the array Arr contains
23 20 5 11 10
Then the array should become
46 60 10 22 30
Note :
• The function should not display the content of the array.
(b) Write definition for a function TOPBOTTOM(int M[][5],int N,int M) in C++,
which finds and displays sum of the values in topmost row and sum of the values in
bottommost row of a matrix M (Assuming the parameter N represents number of
Row and the parameter M represents number of Columns). 3
For example, if the content of array M having N as 4 and M as 5 is as follows :
10 20 30 40 50
12 15 32 4 15
38 4 11 24 15
5 10 15 20 25

91 6
The function should find the sum and display the same as :
Sum of Top Row : 150
Sum of Bottom Row : 75
(c) G[15][20] is a two dimensional array, which is stored in the memory along the
column with each of its element occupying 4 bytes, find the address of the element
G[5] [10], if the element G[2] [4] is stored at the memory location 52000. 3
(d) Write the definition of a member function PUSHBOOK( ) in C++ to add
information of BOOL in a static stack implemented using an array of structure
BOOK (definition of struct BOOK is defined below for reference). 4
struct BOOK
{
int BNO;
char TITLE[20];
};
(e) Evaluate the following Postfix expression showing the stack contents for each step
of conversion. 2
50,40,-,4,5,*,+

4. (a) Write a function definition ARTICLES() in C++ to count all the articles “the”, “a”
and “an” present in a text file “BOOK.TXT”. 3
Note : Ensure that “the”, “a” and “an” are counted as independent words and not as
a part of any other word.
Example :
If the following is content in the file BOOK.TXT :
We should choose a low fat diet. The chef is really good
in the hotel. An article came in the newspaper about him.

The function ARTICLE( ) should display the following output :


5
(b) Write definition of a function CALSAL( ) in C++ to find the total salary paid to all
the workers in a company. The worker’s detail of this company is stored in a binary
file WORKERS.DAT. 2
Assume that the file WORKERS.DAT is created with the help of objects of class
WORKER, which is defined below :
class WORKER
{
int WID; char Name[20];
float Salary;
91 7 [P.T.O.
public:
void INPUT()
{
cin>>WID;gets(Name);cin>>Salary;
}
void OUTPUT()
{
cout<<WID<<":"<<Name<<end1;
cout<<Salary<<endl;
}
float *GetSal(){return Salary;}
};
(c) Find the output of the following C++ code considering that the binary file
PRODUCT.DAT exists on the hard disk with a list of data of 350 products. 1
class PRODUCT
{
int PCode;char PName[20];
public:
void Entry();void Disp();
};
void main()
{
fstream In;
In.open("PRODUCT.DAT",ios::binary|ios::in);
PRODUCT P;
In.seekg(0,ios::end);
cout<<"Total Count: "<<In.tellg()/sizeof(P)<<endl;
In.seekg(70*sizeof(P));
In.read((char*)&P, sizeof(P));
In.read((char*)&P, sizeof(P));
cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
In.close();
}

91 8
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) elif
(ii) BREAK
(iii) in
(iv) _Total
(b) Name the Python Library modules which need to be imported to invoke the
following functions : 1
(i) ceil()
(ii) randint()
(c) Rewrite the following code in Python after removing all syntax error(s). Underline
each correction done in the code. 2
NUM1=1234
1=DAY1
for C in range[1,4]:
NUM+C=NUM1
DAY1=DAY1+2
print C
print NUM1:DAY1
(d) Find and write the output of the following Python code : 2
L1 = [100,900,300,400,500]
START = 1
SUM = 0
for C in range (START,4):
SUM = SUM + L1[C]
print C,":",SUM
SUM = SUM + L1[0]*10
print SUM
(e) Find and write the output of the following Python code : 3
class BOX:
def_init_(self,C=1,L=1,B=1,H=1): #constructor
self.C=C
self.L=L
self.B=B;
self.H=H;
def New(self,Size):
self.L = self.L + Size
self.B = self.B + Size
def Raise(self,Height):
self.H = self.H + Height
def Dimension(self):
print self.C,":",self.L,"x",self.B,"x",self.H
B1=BOX()
B2=BOX(15,5,4)
B3=BOX(101,3,2,4)
B1.Raise(10)
91 9 [P.T.O.
B1.Dimension()
B3.New(5)
B3.Dimension()
B2.New(15)
B2.Dimension()
(f) What are the possible outcome(s) executed from the following code ? Also specify
the maximum and minimum values that can be assigned to variable N. 2
import random
PLAY=[40,50,10,20]"EAST","WEST","NORTH","SOUTH";
ROUND=random.randint(2,3)
for J in range(ROUND,1,–1):
print PLAY[J],”:”
(i) 20:10: (ii) 20:10:50:
(iii) 20: (iv) 40:50:20:

2. (a) List four characteristics of Object Oriented Programming. 2


(b) class ITEM: 2
Ino = 1
Qty = 75
def Get(self,I,Q): #function 1
Ino = I
Qty = Q
def_init_(self,I,Q): #function 2
self.Ino = I
self.Qty = Q
def Display(self): #function 3
print self.Ino,self.Qty
print Ino,Qty
(i) Differentiate between function 1 and function 2 with respect to their
execution.
(ii) Write statements, which will execute function 1 and function 2.
(c) Define a class RING in Python with following specifications : 4
Instance Attributes
- RingID # Numeric value with a default value 101
– Radius # Numeric value with a default value 10
– Area # Numeric value
Methods:
– AreaCal() # Method to calculate Area as
# 3.14*Radius*Radius
– NewRing() # Method to allow user to enter values of
# RingID and Radius. It should also
# Call AreaCal Method

91 10
– ViewRing() # Method to display all the Attributes
Instance Attributes
- FID # data member of integer type
- Height # data member of float type
- Width # data member of float type
- Amount # data member of float type
Methods:
- GetAmount()# Member function to calculate and assign
# Amount as 10*Height*Width
- GetDetail() # A function to allow user to enter values of
# FID, Height, Width. This function should
# also call GetAmount() function to calculate
# Amount

- DispDetail() # A function to display the


# values of all data members
(d) Write a program in Python to input a number and display its each digit reversed.
Example :
If the number is 6534
The program should display 4345 2
(e) Write any two features that make it an important characteristic of Object Oriented
Programming. 2

3. (a) What will be the status of the following list after the First, Second and Third pass
of the bubble sort method used for arranging the following elements in descending
order ? 3
Note : Show the status of all the elements after each pass very clearly underlining
the changes.
52, -10, 34, 60, -19, 20
(b) Write definition of a method ZeroEndingSum(POINTS) to add those values in the
list of POINTS, which are ending with 0. 3
(c) Write AddScore(GAME) and DelScore(GAME) methods in Python to Add a new
SCORE in the list of scores of a GAME and Remove a SCORE from a list of
scores of a GAME, considering these methods to act as PUSH and POP operations
of the data structure Stack. 4
91 11 [P.T.O.
(d) Write definition of a Method SEARCHNAME(MEMBERS, NAME) to search and
display the serial number of first presence of a NAME from a list of MEMBERS. 2

For example :

If the list of MEMBERS contain

["ZAHEEN","TOM","CATHERINE","AMIT","HEENA"]

And

The NAME to search is "CATHERINE"

The following should get displayed

(e) Evaluate the following Postfix notation of expression : 2

20,30,+,180,20,3,*,/,-

4. (a) Differentiate between file modes r+ and r with respect to Python. 1

(b) Write a method in Python to read lines from a text file NOTES.TXT, and count
those lines, which are ending with ‘.’ or ‘,’. 2

(c) Considering the following definition of class FURNITURE, write a method in


Python to search and display the content in a pickled file COMPANY.DAT, where
FTYPE is matching with the value ‘HOME’. 3

class FURNITURE:

def_init_(self,CODE,FTYPE,PRICE):

self.CODE = CODE

self.FTYPE = FTYPE

self.PRICE = 1000

def Display(self):

print self.CODE,":",self.FTYPE,":",self.PRICE
91 12
SECTION – C

(For all the Candidates)

5. (a) Observe the following table CANDIDATE 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 OUTPUT ? Also, find the Degree and Cardinality of the OUTPUT. 2

TABLE _ A

NO ALPHA

C1 X

C2 Y

C3 Z

TABLE _ B

CODE VALUE

101 3000

102 4000

OUTPUT

NO ALPHA CODE VALUE

C1 X 101 3000

C1 X 102 4000

C2 Y 101 3000

C2 Y 102 4000

C3 Z 101 3000

C3 Z 102 4000

(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii),
which are based on the tables : 6
91 13 [P.T.O.
TABLE : SALESPERSON

Code NAME SALARY ITCODE

1001 TANDEEP JHA 60000 I2

1002 YOGRAJ SINHA 70000 I5

1003 TENZIN JACK 45000 I2

1005 ANOKHI RAJ 50000 I7

1004 TARANA SEN 55000 I7

TABLE : ITEM
ITCODE ITEMTYPE TURNOVER
I5 STATIONARY 3400000
I7 HOSIERY 6500000
I2 BAKERY 10090000
(i) To display the CODE and NAME of all SALESPERSON having “I7” Item
Type Code from the table SALESPERSON.
(ii) To display all details from table SALESPERSON in descending order of
SALARY.
(iii) To display the number of SALESPERSON dealing in each TYPE of ITEM.
(Use ITCODE for the same)
(iv) To display NAME of all the salespersons from the SALESPERSON table
along with their corresponding ITEMTYPE from the ITEM table.
(v) SELECT MAX(SALARY) FROM SALESPERSON;
(vi) SELECT DISTINCT ITCODE FROM SALESPERSON;
(vii) SELECT CODE,NAME, I.ITCODE
FROM SALESPERSON S, ITEM I
WHERE S.ITCODE=I.ITCODE AND TURNOVER>=700000;
(viii) SELECT SUM(SALARY) FROM SALESPERSON
WHERE ITCODE=”I2”;

6. (a) State Absorption Laws of Boolean Algebra and verify them using truth table. 2
(b) Draw the Logic Circuit of the following Boolean Expression using only NOR
Gates : 2
A. B’+ C
91 14
(c) Derive a Canonical POS expression for a Boolean function F, represented by the
following truth table : 1
A B C F(A,B,C)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(d) Reduce the following Boolean Expression to its simplest form using K-Map : 3
F(P,Q,R,S) = Σ(0,1,2,3,4,5,6,9,13)

7. (a) Write one name of wireless and one wired communication medium. 2
(b) Name any two private Internet Service Providers (company) in India. 2
(c) Pratibha is an IT expert and a freelancer. She is undertakes those jobs, which are
related to setting up security software/tools and managing networks in various
companies. If we name her role in these companies, what it will be out of the
following : 2
(i) Cracker
(ii) Network Admin
(iii) Hacker
(iv) Operator (justify the reason for you chosen option)
(d) Go-Fast corporation is a Hyderabad based company, which is planning to set up
training campuses in various cities in next 3 years. Their first campus is coming up
in Pune. At Pune campus, they are planning to have 4 different blocks for HR, Web
Design Training, Programming Training and Hardware Training. Each block has
number of computers, which are required to be connected in a network for
communication, data and resource sharing.
As a network consultant of this company, you have to suggest the best network
related solutions for them for issues/problems raised in (i) to (iv), keeping in mind
the distances between various blocks/locations and other given parameters.

91 15 [P.T.O.
Shortest distances between various blocks/locations :
Programming Block to HR Block 60 metres
Programming Block to Web Design Block 50 metres
Programming Block to Hardware Block 70 metres
HR Block to Web Design Block 120 metres
HR Block to Hardware Block 85 metres
HYDERABAD Head Office to PUNE Campus 504 Km
Number of Computers installed at various blocks are as follows :
HR Block 10
Programming Block 100
Web Design Block 60
Hardware 40
(i) Suggest the most appropriate block/location to house the SERVER in the
PUNE Campus (out of the 4 blocks) to get the best and effective connectivity.
Justify your answer. 1
(ii) Suggest a device/software to be installed in the PUNE Campus to take care of
data security. 1
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to
efficiently connect various Blocks within the PUNE campus. 1
(iv) Suggest a device and the protocol that shall be needed to provide Video
Conferencing solution between PUNE Campus and Hyderabad Head Office. 1

___________

91 16

You might also like