CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Arrays Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE ARRAYS 3.b) An array Array[20][15] is stored in the memory along the column with each element occupying 8 bytes. Find out the base address of the element Array[2][3] if the element Array[4][5] is stored at the address 1000. Solution:
Address of an element (I,J) in
column major =B + W ( (I-Lr) + R(J-Lc ) )
Therefore Address of
Array[2][3]=168+8*((2-0)+20(3-0))
3.d) Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the elements which lie on diagonals. [Assuming the 2D Array to be a square matrix with odd dimension i.e., 3x3, 5x5 ,7x7 etc…] Example : if the array content is
Out put through the function should be :
Solution:
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] ) |
|