Data Structure
T[25][30] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element T[10][15], if the element T[5][10] is stored at the memory location 25000.
LOC(T[10][15]) = LOC(T[5][10]) + 2(30*(10-5) + (15-10))
= 25000 + 2(150 + 5)
= 25000 + 2(155)
= 25000 + 310
= 25310
Sponsor Area
A two-dimensional array P[20] [50] is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element [10] [30], if the element P[5] [5] is stored at the memory location 15000.
Write the definition of a member function Pop() in C++, to delete a book from a dynamic stack of TEXTBOOKS considering the following code is already included in the program.
struct TEXTBOOKS
{
char ISBN[20]; char TITLE[80];
TEXTBOOKS *Link;
};
class STACK
{
TEXTBOOKS *Top;
public:
STACK(){Top=NULL;}
void Push();
void Pop();
~STACK();
};
Write a function REVCOL (int P[] [5], int N, int M) in C++ to display the content of a two-dimensional array, with each column content in reverse order.
Note: Array may contain any number of rows.
For example, if the content of the array is as follows:
15 | 12 | 56 | 45 | 51 |
13 | 91 | 92 | 87 | 63 |
11 | 23 | 61 | 46 | 81 |
The function should display output as:
11 | 23 | 61 | 46 | 81 |
13 | 91 | 92 | 87 | 63 |
15 | 12 | 56 | 45 | 51 |
Write a function ALTERNATE (int A[][3],int N,int M) in C++ to display all alternate element from two-dimensional array A (starting from A[0][0]).
For example:
If the array is containing:
23 | 54 | 76 |
37 | 19 | 28 |
62 | 13 | 19 |
The output will be:
23 | 76 | 19 | 62 | 19 |
Sponsor Area
Sponsor Area