Page 219 - C++
P. 219
regno integer(ranges 10-100)
name String
type character
cost float
Public members:
function readdata( ) to read an object of Housing type.
Function display( ) to display the details of the object.
Function drawNumbers( ) to choose and display the details of 2 houses selected
randomly from an array of 10 objects of type Housing.
Use random function to generate the registration numbers to match with regno from
array. [4]
d) Consider the following class and answer the questions that follow:
class School
{
int a;
protected:
int b,c;
public:
void input (int);
void output( );
};
class Dept: protected School
{
int x,y;
protected:
void In(int, int);
public:
void Out( );
};
class Teacher: protected Dept
{
int p;
public:
void enter( );
};
(i) Can the function input( ) and output( ) access the data member p in class “Teacher”.
Justify your answer.
(ii) What will be the size of the object Teacher?
(iii) What are the data members that are/is accessible from the member function enter( ) in
class Teacher?
(iv) Write the names of all the members that are accessible from the objects of class Dept. [4]
Q.3 a) The following numbers (89, 20, 31, 56, 20, 64, 48) are required to be sorted using insertion sort
showing how the list would appear at the end of each pass.
Note- The program is not to be written. [2]
b) An array M[-3…18][-8…37] is stored in the memory along the column with each of its elements
occupying 8 bytes. Find out the base address and the address of an element M[2][5], if the
M[5][10] is stored at address 4000. [3]
c) Write a function in C++ which accepts a 2D array of integers, number of rows and number of
columns as arguments and assign the elements which are divisible by 3 or 5 into a one
3