Page 300 - C++
P. 300
CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
(Sub Code: 083 Paper Code 91 Outside Delhi)
LOC(ARR[10][5])
35000 = BaseAddress + W(I*C + J)
35000 = BaseAddress + 4(10*20 + 5)
35000 = BaseAddress + 4(205)
35000 = BaseAddress + 820
BaseAddress = 35000 - 820
= 34180
LOC(ARR[5][15])= BaseAddress + W(I*C + J)
= 34180 + 4(5*20 + 15)
= 34180 + 4(100 + 15)
= 34180 + 4 x 115
= 34180 + 460
= 34640
OR
Loc(ARR[I][J]) = Ref. Address + W (( I – LR)*C + (J – LC))
(where
W=size of each element = 4 bytes,
R=Number of Rows =15, C=Number of Columns=20
Reference Address= Address of given cell ARR[10][5]=35000
LR = Row value of given cell = 10
LC = Column value of given cell = 5
LOC(ARR[5][15]) = LOC(ARR[10][5]) + 4((5-10)*20 + (15-5))
LOC(ARR[5][15]) = 35000 + 4(-100 + 10)
= 35000 + 4[-90]
= 35000 -360
= 34640
(1 Mark for writing correct formula (for Row major) OR substituting
formula with correct values)
(1Mark for correct calculation)
(1 Mark for final correct address)
(d) Write the definition of a member function PUSHGIFT() for a class STACK in C++, 4
to add a GIFT in a dynamically allocated stack of GIFTs considering the following
code is already written as a part of the program:
struct GIFT
{
int GCODE; //Gift Code
char GDESC[20]; //Gift Description
GIFT *Link;
};
class STACK
{
Gift *TOP;
public:
STACK(){TOP=NULL;}
void PUSHGIFT();
void POPGIFT();
~STACK();
};
Page #10 of 28