1.

ARR[15] [20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[5][15], if the element ARR[ 10] [5] is stored at the memory location 35000. (d) Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a GIFT in a dynamically allocated stack of GGIFTs considering the following code is already written as a part of the program:struct GIFT{int GCODE; //Gift Codechar GDESC[20]: //Gift DescriptionGIFT *Link;};class STACK{Gift * T0P; .public:STACK(){T0P=NULL;}void PUSHGIFT():void POPGIFT();~STACK();};

Answer»

void PUSHGIFT( )

{

GIFT *G = new GIFT;

cout<<"Enter gift code and description";

cout>>G->GCODE;

gets(G->GDESC);

if (TOP == NULL)

{

TOP = G:

}

else

{

G->Link = TOP

TOP = G;

}

}



Discussion

No Comment Found

Related InterviewSolutions