Академический Документы
Профессиональный Документы
Культура Документы
Time: 3 hrs.
SECTION A (C++)
MM: 70
{
long Cust_no;
char Cust_Name[20];
protected:
int Register(oat);
public:
CUSTOMER(long double);
char Status(char);
};
class B: public A
{
long Salesman_no;
char Salesman_Name[20];
protected:
oat Salary;
public:
SALESMAN( );
double Enter( );
int Show( );
};
class C : private B
{
char Voucher_No[10];
public:
SHOP( );
char Sales_Date[8];
oat Sales_Entry( );
char Sales_Detail( );
};
void main( )
{
C Z;
}
(i) Write the names of members which are
accessible through Z.
(ii) What type of inheritance is implemented in
the above example.
(iii) Write the names of all the data members
which are accessible from class C.
(iv) How many bytes will be required by an
object of class B and class C?
Q3.(a) Convert the following inx expression to its
equivalent postx expression.
2
A * B / ( C ^ D / E ^ F) G
(b) An array A[10][30] is stored in the memory along
the column with each of its elements occupying
4 bytes. Find out the address of an element
A[2][5], if the location A[5][10] is stored at the
address 4000.
2
(c) An array B[16][[37] is stored in memory with
each element required 4 bytes of storage. If the
base address is 3000, determine the location of
B[3][6] when the array is stored as row major. 2
(d) Given a structure named as Book having
members book id and book title. Dene a
function Bubble_Sort( ) having array of
structure Book and its the size of the array as
its argument. The function is required to sort the
array of Book in ascending order on the key:
book id using bubble sort.
3
(g) Give the necessary declaration of class for the
linked implemented stack through dening the
functions to push and pop the nodes. Each node
is containing ItemCode (int) and Price (oat) in
addition to pointer eld.
4
(h) Consider the following key set: 74, 11, 65,
58, 42, 29 use selection sort to sort the data in
ascending order and indicate the sequences of
steps required.
2
Q4 a) The le content before each time the program
is executed is the string VANASTHALI
3
(Note that are not part of the le).
void main( )
{
_______________________;
//
Statement
fobj<<MY;
fobj.seekg(0,ios::end);
cout<<Result is <<fobj.tellg( );
}
What shell be the output and what shell be the
contents of the le after execution of the above
code segment.
Consider the following cases for the
_________________//
Statement
i) fstream fobj(data.dat,ios::out | ios::in);
ii) fstream fobj(data.dat,ios::app | ios::in);
iii) fstream fobj(data.dat,ios::out);
b) Given the class TABLE below. Write the
functions in C++ to perform the following:
3
A function to write objects of TABLE to a binary
le.
Another function to read objects of TABLE from
binary le and display them.
class TABLE
{ int height;
char colour[10];
public:
void getdata( ) { cin>>height; gets(colour); }
void
showdata(
)
{
cout<<height<<
<<colour<<endl;}
};
SECTION : B (PYTHON)
GENERAL
INSTRUCTION
x//=2
else
print pow(2,11)
x=-6
d) Give the output of following
[2]
k=[4,2,6,8,9]
m=k
m[1]=55
for a in [2,1,3]:
print m[a]
else:
print k is ,k
e) What are the possible outcome(s) expected
from the following python code? Also specify
maximum and minimum value, which we can
have.
[2]
from random import *
a=3
while a:
print int(random()*10+5),#,
a-=1
I. 1 # 6 # 11 #
II. 12 # 7 # 8 #
III. 10 # 9 # 11 #
IV. 14 # 15 # 7 #
V. 14 # 9 # 4 #
f) Illustrate the concept of inheritance with the help of
python code
[3]
Q2. a) Explain garbage collection.
[2]
b) What will following python code produce [2]
try:
print a,
statement1
except TypeError:
print b,
except ZeroDivisionError:
print c,
except:
print d,
else:
print e,
nally:
print f,
Replacing statement1 with
i) print 9/2,
ii) print 9/0,
iii) print 2+3
iv) print 7/r
Give output of each individually
c) Write a class Mouse in python with the following
specications:
[4]
Instance Attributes
SerialNo
#numeric value
Type
#String Value
Make
#String Value
Price
#Nemeric Value
Methods:
Read ( )
#A method with 4 argumets to set the
value of all of its instance variables
Dene function _ _str_ _ ( ) helping function show
( ) to display details
Show ( ) #Invoking function _ _str_ _( )
Overload the + operator returning the sum of price
of two mouse.
d) What are the different ways of overriding function
call in derived class of python? Illustrate with
example.
[2]
e) Write a python function returning the list of
composite numbers in the range 50 to 100 [2]
Q3. a) Show the steps to sort the following elements
in descending order using insertion sort method.
40, 67, -23, 11, 27, 38, -1
[2]
b) Write a python function to sort a list of integers
using selection sort method. Function should
receive the list of numbers to be sorted as its
argument.
[2]
c) Dene queue class in python to operate on queue
of numbers.
[4]
d) Write a python generator function to generate
prime numbers till the value provided as
parameter to it.
[2]
e) Evaluate the following postx expression. Show
the status of stack after execution of each
operation separately: (Hint: Ans is True/1 or
False/0)
5,10, , 2, ,11,14, , 12, * , /
[2]
f) Convert the following inx expression to postx
expression using stack. Show the status of stack
after execution of each operation:
A(B+C)/ D+EF*G
[2]
Q4.a) Differentiate between w+ and r+ modes in
python.
[1]
b) Given a pickled le - log.dat, containing
multiple strings. Write a python function that
reads the le and looks for a string of the form
Xerror: 0.2395
whenever such string is encountered, extract
the oating point value and compute the total
of these error values. When you reach end of
le print total number of such error lines and
average of error value.
[3]
c) Given a text le student.dat containing information
of students in following format
RNo, Name, Marks (i.e. each eld is separated
using , (comma))
Write a python function to display names of all
those students whose marks are above 90 also
give the average marks of all of the students who
attain marks in range 70 to 90.
[2]
SECTION : C
ID
101
104
107
114
109
105
117
111
130
NAME
ANKIT
SUMIT
YOGENDER
RAVI
FIZA
VIKAS
DAISY
RACHNA
SATPAL SINGH
DEPT
SEX EXPERIENCE
ENT
M
12
ORTHOPEDIC
M
5
CARDIOLOGY M
10
SKIN
F
3
MEDICINE
F
9
ORTHOPEDIC
M
10
ENT
F
3
MEDICINE
F
12
ORTHOPEDIC
M
15
TABLE: SALARY
ID BASIC
101 12000
104 23000
107 32000
114 12000
109 42000
105 18900
130 21700
ALLOWANCE
1000
2300
4000
5200
1700
1690
2600
CONSULTATION
300
500
500
100
200
300
300