Answer the questions (i) to (iv) based on the following:
class PRODUCT
{
int Code;
char Item[20];
protected:
float Qty;
public:
PRODUCT();
void GetIn(); void Show();
};
class WHOLESALER
{
int WCode;
protected:
char Manager[20];
public:
WHOLESALER();
void Enter();
void Display();
};
class SHOWROOM : public PRODUCT, private WHOLESALER
{
char Name[20],City[20];
public:
SHOWROOM();
void Input();
void View();
}
(i)Which type of Inheritance out of the following is illustrated in the above example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class SHOWROOM.
(iii) Write the names of all the member functions, which are directly accessible by an object of class SHOWROOM.
(iv) What will be the order of execution of the constructors, when an object of class SHOWROOM is declared?
Write the definition of a function FixPay(float Pay[], int N) in C++, which should modify each element of the array Pay having N elements, as per the following rules:
Existing Value of Pay | Pay to be changed to |
If less than 100000 | Add 25% in the existing value |
If >=100000 and <20000 | Add 20% in the existing value |
If >=200000 | Add 15% in the existing value |
T[20][50] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element T[15][5], if the element T[10][8] is stored at the memory location 52000.
Write the definition of a member function INSERT() for a class QUEUE in C++, to insert an ITEM in a dynamically allocated Queue of items considering the following code is already written as a part of the program.
struct ITEM
{
int INO; char INAME[20];
ITEM *Link;
};
class QUEUE
{
ITEM *R,*F;
public :
QUEUE() {R=NULL;F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};
Write a definition for a function SHOWMID (int P[][5], int R, int C) in C++ to display the elements of the middle row and middle column from a two-dimensional array P having R number of rows and C number of columns. For example, if the content of the array is as follows:
115 | 112 | 116 | 101 | 125 |
103 | 101 | 121 | 102 | 101 |
185 | 109 | 109 | 160 | 172 |
The function should display the following as output :
103 101 121 102 101
116 121 109
Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
A/(B+C)*DE
A/(B+C)*DE
= (A / (B+C) * D E)
Element | Stack of Operators | Postfix Expression |
( | ( | |
A | ( | A |
/ | (/ | A |
( | (/( | A |
B | (/( | AB |
+ | (/(+ | AB |
C | (/(+ | ABC |
) | (/ | ABC+ |
* | (* | ABC+/ |
D | (* | ABC+/D |
- | (- | ABC+/D* |
E | (- | ABC+/D*E |
) | ABC+/D*E- |
ABC+/D*E
Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TXT, and display all those words, which has four characters in it.
Example:
If the content of the file fun.TXT is as follows:
When I was a small child, I used to play in the garden
with my grand mom. Those days were amazingly funful
and I remember all the moments of that time
The function WORD4CHAR() should display the following:
When used play with days were that time
Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFTS.DAT, find and display details of those gifts, which has remarks as ON DISCOUNT. Assume that the file GIFTS.DATis created with the help of objects of class GIFTS, which is defined below:
class GIFTS
{
int ID;char Gift[20],Remarks[20]; float Price;
public:
void Takeonstock()
{
cin>>ID;gets(Gift);gets(Remarks);cin>>Price;
}
void See()
{
cout<<ID<<':'<<Gift<<':'<<Price<<':'<<Remarks<<endl;
}
char *GetRemarks(){return Remarks;}
}
Find the output of the following C++ code considering that the binary file MEM.DAT exists on the hard disk with a data of 1000 members.
class MEMBER
{
int Mcode;char MName[20];
public:
void Register();void Display();
};
void main()
{
fstream MFile;
MFile.open('MEM.DAT',ios::binary|ios::in);
MEMBER M;
MFile.read((char*)&M, sizeof(M));
cout<<'Rec:'<<MFile.tellg()/sizeof(M)<<endl;
MFile.read((char*)&M, sizeof(M));
MFile.read((char*)&M, sizeof(M));
cout<<'Rec:'<<MFile.tellg()/sizeof(M)<<endl;
MFile.close();
}